NewInspectCommand creates a new `docker manifest inspect` command
(dockerCLI command.Cli)
| 23 | |
| 24 | // NewInspectCommand creates a new `docker manifest inspect` command |
| 25 | func newInspectCommand(dockerCLI command.Cli) *cobra.Command { |
| 26 | var opts inspectOptions |
| 27 | |
| 28 | cmd := &cobra.Command{ |
| 29 | Use: "inspect [OPTIONS] [MANIFEST_LIST] MANIFEST", |
| 30 | Short: "Display an image manifest, or manifest list", |
| 31 | Args: cli.RequiresRangeArgs(1, 2), |
| 32 | RunE: func(cmd *cobra.Command, args []string) error { |
| 33 | switch len(args) { |
| 34 | case 1: |
| 35 | opts.ref = args[0] |
| 36 | case 2: |
| 37 | opts.list = args[0] |
| 38 | opts.ref = args[1] |
| 39 | } |
| 40 | return runInspect(cmd.Context(), dockerCLI, opts) |
| 41 | }, |
| 42 | DisableFlagsInUseLine: true, |
| 43 | } |
| 44 | |
| 45 | flags := cmd.Flags() |
| 46 | flags.BoolVar(&opts.insecure, "insecure", false, "Allow communication with an insecure registry") |
| 47 | flags.BoolVarP(&opts.verbose, "verbose", "v", false, "Output additional info including layers and platform") |
| 48 | return cmd |
| 49 | } |
| 50 | |
| 51 | func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions) error { |
| 52 | namedRef, err := normalizeReference(opts.ref) |
searching dependent graphs…