(ctx context.Context, dockerCli command.Cli, opts inspectOptions)
| 49 | } |
| 50 | |
| 51 | func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions) error { |
| 52 | namedRef, err := normalizeReference(opts.ref) |
| 53 | if err != nil { |
| 54 | return err |
| 55 | } |
| 56 | |
| 57 | // If list reference is provided, display the local manifest in a list |
| 58 | if opts.list != "" { |
| 59 | listRef, err := normalizeReference(opts.list) |
| 60 | if err != nil { |
| 61 | return err |
| 62 | } |
| 63 | |
| 64 | imageManifest, err := newManifestStore(dockerCli).Get(listRef, namedRef) |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | return printManifest(dockerCli, imageManifest, opts) |
| 69 | } |
| 70 | |
| 71 | // Try a local manifest list first |
| 72 | localManifestList, err := newManifestStore(dockerCli).GetList(namedRef) |
| 73 | if err == nil { |
| 74 | return printManifestList(dockerCli, namedRef, localManifestList, opts) |
| 75 | } |
| 76 | |
| 77 | // Next try a remote manifest |
| 78 | registryClient := newRegistryClient(dockerCli, opts.insecure) |
| 79 | imageManifest, err := registryClient.GetManifest(ctx, namedRef) |
| 80 | if err == nil { |
| 81 | return printManifest(dockerCli, imageManifest, opts) |
| 82 | } |
| 83 | |
| 84 | // Finally try a remote manifest list |
| 85 | manifestList, err := registryClient.GetManifestList(ctx, namedRef) |
| 86 | if err != nil { |
| 87 | return err |
| 88 | } |
| 89 | return printManifestList(dockerCli, namedRef, manifestList, opts) |
| 90 | } |
| 91 | |
| 92 | func printManifest(dockerCli command.Cli, manifest types.ImageManifest, opts inspectOptions) error { |
| 93 | buffer := new(bytes.Buffer) |
no test coverage detected
searching dependent graphs…