(ctx context.Context, dockerCLI command.Cli, img string, options *createOptions)
| 133 | } |
| 134 | |
| 135 | func pullImage(ctx context.Context, dockerCLI command.Cli, img string, options *createOptions) error { |
| 136 | encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), img) |
| 137 | if err != nil { |
| 138 | return err |
| 139 | } |
| 140 | |
| 141 | var ociPlatforms []ocispec.Platform |
| 142 | if options.platform != "" { |
| 143 | // Already validated. |
| 144 | ociPlatforms = append(ociPlatforms, platforms.MustParse(options.platform)) |
| 145 | } |
| 146 | resp, err := dockerCLI.Client().ImagePull(ctx, img, client.ImagePullOptions{ |
| 147 | RegistryAuth: encodedAuth, |
| 148 | Platforms: ociPlatforms, |
| 149 | }) |
| 150 | if err != nil { |
| 151 | return err |
| 152 | } |
| 153 | defer func() { |
| 154 | _ = resp.Close() |
| 155 | }() |
| 156 | |
| 157 | out := dockerCLI.Err() |
| 158 | if options.quiet { |
| 159 | out = streams.NewOut(io.Discard) |
| 160 | } |
| 161 | return jsonstream.Display(ctx, resp, out) |
| 162 | } |
| 163 | |
| 164 | type cidFile struct { |
| 165 | path string |
no test coverage detected
searching dependent graphs…