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

Function shortenImageDigest

cmd/validate/vsa.go:702–721  ·  view source on GitHub ↗

Helper functions shortenImageDigest extracts and shortens image digest to 8 characters

(imageRef string)

Source from the content-addressed store, hash-verified

700
701// shortenImageDigest extracts and shortens image digest to 8 characters
702func shortenImageDigest(imageRef string) string {
703 // Extract digest from image reference (format: registry/repo@sha256:digest)
704 parts := strings.Split(imageRef, "@")
705 if len(parts) < 2 {
706 // No digest, return first 8 chars of image ref
707 if len(imageRef) > 8 {
708 return "…" + imageRef[len(imageRef)-8:]
709 }
710 return imageRef
711 }
712
713 digest := parts[1]
714 // Remove sha256: prefix if present
715 digest = strings.TrimPrefix(digest, "sha256:")
716 // Return first 8 characters
717 if len(digest) >= 8 {
718 return digest[:8]
719 }
720 return digest
721}
722
723// extractFallbackReason extracts the reason for fallback from ValidationResult
724// Prefers structured ReasonCode field, falls back to message parsing for backward compatibility

Callers 2

aggregateAllSectionsDataFunction · 0.85
TestShortenImageDigestFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestShortenImageDigestFunction · 0.68