MCPcopy Create free account
hub / github.com/docker/cli / GetImageReferencesAndAuth

Function GetImageReferencesAndAuth

cmd/docker-trust/internal/trust/trust.go:342–368  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

340// GetImageReferencesAndAuth retrieves the necessary reference and auth information for an image name
341// as an ImageRefAndAuth struct
342func 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
370func getTag(ref reference.Named) string {
371 switch x := ref.(type) {

Callers

nothing calls this directly

Calls 3

authResolverFunction · 0.85
getTagFunction · 0.85
getDigestFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…