ImageDigestResolver creates a func able to resolve image digest from a docker ref,
(ctx context.Context, file *configfile.ConfigFile, apiClient client.APIClient)
| 257 | |
| 258 | // ImageDigestResolver creates a func able to resolve image digest from a docker ref, |
| 259 | func ImageDigestResolver(ctx context.Context, file *configfile.ConfigFile, apiClient client.APIClient) func(named reference.Named) (digest.Digest, error) { |
| 260 | return func(named reference.Named) (digest.Digest, error) { |
| 261 | auth, err := encodedAuth(named, file) |
| 262 | if err != nil { |
| 263 | return "", err |
| 264 | } |
| 265 | inspect, err := apiClient.DistributionInspect(ctx, named.String(), client.DistributionInspectOptions{ |
| 266 | EncodedRegistryAuth: auth, |
| 267 | }) |
| 268 | if err != nil { |
| 269 | return "", |
| 270 | fmt.Errorf("failed to resolve digest for %s: %w", named.String(), err) |
| 271 | } |
| 272 | return inspect.Descriptor.Digest, nil |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | type authProvider interface { |
| 277 | GetAuthConfig(registryHostname string) (clitypes.AuthConfig, error) |
no test coverage detected