func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() getRefFunc := func(ref string) (interface{}, []byte, error) { return client.ImageInspectWithRaw(ctx, ref) } return inspect.Inspect(dockerCli.Out(), opts.refs, opts.format, getRefFunc) }
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { var elementSearcher inspect.GetRefFunc switch opts.inspectType { case "", "container", "image", "node", "network", "service", "volume", "task", "plugin": elementSearcher = inspectAll(context.Background(), dockerCli, opts.size, opts.inspectType) default: return fmt.Errorf("%q is not a valid value for --type", opts.inspectType) } return inspect.Inspect(dockerCli.Out(), opts.ids, opts.format, elementSearcher) }
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() getNetFunc := func(name string) (interface{}, []byte, error) { return client.NetworkInspectWithRaw(ctx, name) } return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getNetFunc) }
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() getVolFunc := func(name string) (interface{}, []byte, error) { i, err := client.VolumeInspect(ctx, name) return i, nil, err } return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getVolFunc) }
func runSecretInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() ids, err := getCliRequestedSecretIDs(ctx, client, opts.names) if err != nil { return err } getRef := func(id string) (interface{}, []byte, error) { return client.SecretInspectWithRaw(ctx, id) } return inspect.Inspect(dockerCli.Out(), ids, opts.format, getRef) }
func runInspect(dockerCli command.Cli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() getRef := func(ref string) (interface{}, []byte, error) { nodeRef, err := Reference(ctx, client, ref) if err != nil { return nil, nil, err } node, _, err := client.NodeInspectWithRaw(ctx, nodeRef) return node, nil, err } if !opts.pretty { return inspect.Inspect(dockerCli.Out(), opts.nodeIds, opts.format, getRef) } return printHumanFriendly(dockerCli.Out(), opts.nodeIds, getRef) }
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() getRef := func(ref string) (interface{}, []byte, error) { service, _, err := client.ServiceInspectWithRaw(ctx, ref) if err == nil || !apiclient.IsErrServiceNotFound(err) { return service, nil, err } return nil, nil, fmt.Errorf("Error: no such service: %s", ref) } if !opts.pretty { return inspect.Inspect(dockerCli.Out(), opts.refs, opts.format, getRef) } return printHumanFriendly(dockerCli.Out(), opts.refs, getRef) }
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() getRef := func(name string) (interface{}, []byte, error) { named, err := reference.ParseNamed(name) // FIXME: validate if err != nil { return nil, nil, err } if reference.IsNameOnly(named) { named = reference.WithDefaultTag(named) } ref, ok := named.(reference.NamedTagged) if !ok { return nil, nil, fmt.Errorf("invalid name: %s", named.String()) } return client.PluginInspectWithRaw(ctx, ref.String()) } return inspect.Inspect(dockerCli.Out(), opts.pluginNames, opts.format, getRef) }
// ServiceInspectWrite renders the context for a list of services func ServiceInspectWrite(ctx Context, refs []string, getRef inspect.GetRefFunc) error { if ctx.Format != serviceInspectPrettyTemplate { return inspect.Inspect(ctx.Output, refs, string(ctx.Format), getRef) } render := func(format func(subContext subContext) error) error { for _, ref := range refs { serviceI, _, err := getRef(ref) if err != nil { return err } service, ok := serviceI.(swarm.Service) if !ok { return fmt.Errorf("got wrong object to inspect") } if err := format(&serviceInspectContext{Service: service}); err != nil { return err } } return nil } return ctx.Write(&serviceInspectContext{}, render) }
func runSecretInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() // attempt to lookup secret by name secrets, err := getSecretsByName(ctx, client, []string{opts.name}) if err != nil { return err } id := opts.name for _, s := range secrets { if s.Spec.Annotations.Name == opts.name { id = s.ID break } } getRef := func(name string) (interface{}, []byte, error) { return client.SecretInspectWithRaw(ctx, id) } return inspect.Inspect(dockerCli.Out(), []string{id}, opts.format, getRef) }