MCPcopy Create free account
hub / github.com/conforma/cli / ExtractDigestFromImageRef

Function ExtractDigestFromImageRef

internal/validate/vsa/vsa.go:940–956  ·  view source on GitHub ↗

ExtractDigestFromImageRef extracts the digest from an image reference

(imageRef string)

Source from the content-addressed store, hash-verified

938
939// ExtractDigestFromImageRef extracts the digest from an image reference
940func ExtractDigestFromImageRef(imageRef string) (string, error) {
941 // Parse the image reference
942 ref, err := name.ParseReference(imageRef)
943 if err != nil {
944 return "", fmt.Errorf("failed to parse image reference %s: %w", imageRef, err)
945 }
946
947 // Check if it's already a digest reference
948 if digestRef, ok := ref.(name.Digest); ok {
949 return digestRef.DigestStr(), nil
950 }
951
952 // For tag references, we need to resolve to digest
953 // For now, return the image reference as-is and let the retriever handle it
954 // In a full implementation, this would resolve the tag to a digest
955 return imageRef, nil
956}
957
958// isFilePathLike checks if an identifier looks like a file path
959// This handles the case where name.ParseReference incorrectly accepts file paths as valid image references

Calls 1

ErrorfMethod · 0.65

Tested by 1