本文整理汇总了Golang中github.com/docker/docker/cli/command/inspect.Inspect函数的典型用法代码示例。如果您正苦于以下问题:Golang Inspect函数的具体用法?Golang Inspect怎么用?Golang Inspect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Inspect函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runInspect
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)
}
示例2: runInspect
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)
}
示例3: runInspect
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)
}
示例4: runSecretInspect
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)
}
示例5: runInspect
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)
}
示例6: ServiceInspectWrite
// 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)
}
示例7: runSecretInspect
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)
}