docker/policyconfiguration/naming.go
func DockerReferenceIdentity(ref reference.Named) (string, error) {
	res := ref.Name()
	tagged, isTagged := ref.(reference.NamedTagged)
	digested, isDigested := ref.(reference.Canonical)
	switch {
	case isTagged && isDigested: // Note that this CAN actually happen.
		return "", errors.Errorf("Unexpected Docker reference %s with both a name and a digest", reference.FamiliarString(ref))
	case !isTagged && !isDigested: // This should not happen, the caller is expected to ensure !reference.IsNameOnly()
		return "", errors.Errorf("Internal inconsistency: Docker reference %s with neither a tag nor a digest", reference.FamiliarString(ref))
	case isTagged:
		res = res + ":" + tagged.Tag()
	case isDigested:
		res = res + "@" + digested.Digest().String()
	default: // Coverage: The above was supposed to be exhaustive.
		return "", errors.New("Internal inconsistency, unexpected default branch")
	}
	return res, nil
}
func DockerReferenceIdentity(ref reference.Named) (string, error) {
	res := ref.Name()
	tagged, isTagged := ref.(reference.NamedTagged)
	digested, isDigested := ref.(reference.Canonical)
	switch {
	case isTagged && isDigested: // Note that this CAN actually happen.
		return "", errors.Errorf("Unexpected Docker reference %s with both a name and a digest", reference.FamiliarString(ref))
	case !isTagged && !isDigested: // This should not happen, the caller is expected to ensure !reference.IsNameOnly()
		return "", errors.Errorf("Internal inconsistency: Docker reference %s with neither a tag nor a digest", reference.FamiliarString(ref))
	case isTagged:
		res = res + ":" + tagged.Tag()
	case isDigested:
		res = res + "@" + digested.Digest().String()
	default: // Coverage: The above was supposed to be exhaustive.
		return "", errors.New("Internal inconsistency, unexpected default branch")
	}
	return res, nil
}
func DockerReferenceIdentity ( ref reference . Named ) ( string , error ) { res := ref . Name ( ) tagged , isTagged := ref . ( reference . NamedTagged ) digested , isDigested := ref . ( reference . Canonical ) switch { case isTagged && isDigested : // Note that this CAN actually happen. return " " , errors . Errorf ( " " , reference . FamiliarString ( ref ) ) case ! isTagged && ! isDigested : // This should not happen, the caller is expected to ensure !reference.IsNameOnly() return " " , errors . Errorf ( " " , reference . FamiliarString ( ref ) ) case isTagged : res = res + " " + tagged . Tag ( ) case isDigested : res = res + " " + digested . Digest ( ) . String ( ) default : // Coverage: The above was supposed to be exhaustive. return " " , errors . New ( " " ) } return res , nil }
// DockerReferenceIdentity returns a string representation of the reference, suitable for policy lookup,
// as a backend for ImageReference.PolicyConfigurationIdentity.
// The reference must satisfy !reference.IsNameOnly().
DockerReferenceIdentity returns a string representation of the reference suitable for policy lookup as a backend for ImageReference . PolicyConfigurationIdentity . The reference must satisfy !reference . IsNameOnly () .