MCPcopy Index your code
hub / github.com/docker/cli / newInspectCommand

Function newInspectCommand

cli/command/context/inspect.go:22–45  ·  view source on GitHub ↗

newInspectCommand creates a new cobra.Command for `docker context inspect`

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

20
21// newInspectCommand creates a new cobra.Command for `docker context inspect`
22func newInspectCommand(dockerCLI command.Cli) *cobra.Command {
23 var opts inspectOptions
24
25 cmd := &cobra.Command{
26 Use: "inspect [OPTIONS] [CONTEXT] [CONTEXT...]",
27 Short: "Display detailed information on one or more contexts",
28 RunE: func(cmd *cobra.Command, args []string) error {
29 opts.refs = args
30 if len(opts.refs) == 0 {
31 if dockerCLI.CurrentContext() == "" {
32 return errors.New("no context specified")
33 }
34 opts.refs = []string{dockerCLI.CurrentContext()}
35 }
36 return runInspect(dockerCLI, opts)
37 },
38 ValidArgsFunction: completeContextNames(dockerCLI, -1, false),
39 DisableFlagsInUseLine: true,
40 }
41
42 flags := cmd.Flags()
43 flags.StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp)
44 return cmd
45}
46
47func runInspect(dockerCli command.Cli, opts inspectOptions) error {
48 getRefFunc := func(ref string) (any, []byte, error) {

Callers 1

newContextCommandFunction · 0.70

Calls 3

runInspectFunction · 0.70
completeContextNamesFunction · 0.70
CurrentContextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…