DetectIdentifierType detects the type of VSA identifier
(identifier string)
| 762 | |
| 763 | // DetectIdentifierType detects the type of VSA identifier |
| 764 | func 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 |
| 793 | func IsImageReference(identifier string) bool { |