newInspectCommand creates a new cobra.Command for `docker context inspect`
(dockerCLI command.Cli)
| 20 | |
| 21 | // newInspectCommand creates a new cobra.Command for `docker context inspect` |
| 22 | func 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 | |
| 47 | func runInspect(dockerCli command.Cli, opts inspectOptions) error { |
| 48 | getRefFunc := func(ref string) (any, []byte, error) { |
no test coverage detected
searching dependent graphs…