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

Function DetectIdentifierType

internal/validate/vsa/vsa.go:764–790  ·  view source on GitHub ↗

DetectIdentifierType detects the type of VSA identifier

(identifier string)

Source from the content-addressed store, hash-verified

762
763// DetectIdentifierType detects the type of VSA identifier
764func DetectIdentifierType(identifier string) IdentifierType {
765 // Check if it's a file path first - this is more specific than image references
766 if isFilePath(identifier) {
767 return IdentifierFile
768 }
769
770 // Check for image digests (including pure digests)
771 if isImageDigest(identifier) {
772 return IdentifierImageDigest
773 }
774
775 // Try image reference parse - but be more restrictive
776 // Empty strings and pure digests should not be considered image references
777 if identifier != "" && !isPureDigest(identifier) {
778 if _, err := name.ParseReference(identifier); err == nil {
779 return IdentifierImageReference
780 }
781 }
782
783 // last resort: keep as reference so users can pass bare names like "nginx:latest"
784 if identifier != "" && !isPureDigest(identifier) {
785 if _, err := name.ParseReference("docker.io/library/" + identifier); err == nil {
786 return IdentifierImageReference
787 }
788 }
789 return IdentifierFile
790}
791
792// IsImageReference checks if the identifier is an image reference
793func IsImageReference(identifier string) bool {

Callers 6

validateVSAInputFunction · 0.92
TestDetectIdentifierTypeFunction · 0.92
IsImageReferenceFunction · 0.85
IsValidVSAIdentifierFunction · 0.85
CreateVSARetrieverFunction · 0.85

Calls 3

isFilePathFunction · 0.85
isImageDigestFunction · 0.85
isPureDigestFunction · 0.85

Tested by 2

TestDetectIdentifierTypeFunction · 0.74