GetImageReferencesAndAuth retrieves the necessary reference and auth information for an image name as an ImageRefAndAuth struct
(ctx context.Context, authResolver func(ctx context.Context, index *registrytypes.IndexInfo) registrytypes.AuthConfig, imgName string, )
| 340 | // GetImageReferencesAndAuth retrieves the necessary reference and auth information for an image name |
| 341 | // as an ImageRefAndAuth struct |
| 342 | func GetImageReferencesAndAuth(ctx context.Context, |
| 343 | authResolver func(ctx context.Context, index *registrytypes.IndexInfo) registrytypes.AuthConfig, |
| 344 | imgName string, |
| 345 | ) (ImageRefAndAuth, error) { |
| 346 | ref, err := reference.ParseNormalizedNamed(imgName) |
| 347 | if err != nil { |
| 348 | return ImageRefAndAuth{}, err |
| 349 | } |
| 350 | |
| 351 | // Resolve the Repository name from fqn to RepositoryInfo, and create an |
| 352 | // IndexInfo. Docker Content Trust uses the IndexInfo.Official field to |
| 353 | // select the right domain for Docker Hub's Notary server; |
| 354 | // https://github.com/docker/cli/blob/v28.4.0/cli/trust/trust.go#L65-L79 |
| 355 | indexInfo := registry.NewIndexInfo(ref) |
| 356 | authConfig := authResolver(ctx, indexInfo) |
| 357 | return ImageRefAndAuth{ |
| 358 | original: imgName, |
| 359 | authConfig: &authConfig, |
| 360 | reference: ref, |
| 361 | repoInfo: &RepositoryInfo{ |
| 362 | Name: reference.TrimNamed(ref), |
| 363 | Index: indexInfo, |
| 364 | }, |
| 365 | tag: getTag(ref), |
| 366 | digest: getDigest(ref), |
| 367 | }, nil |
| 368 | } |
| 369 | |
| 370 | func getTag(ref reference.Named) string { |
| 371 | switch x := ref.(type) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…