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

Function wrapCosignErrorMessage

internal/output/output.go:336–349  ·  view source on GitHub ↗

wrapCosignErrorMessage wraps the message from the given error indicating the type of check that was performed. It may also completely change the message with a more helpful one in some cases.

(err error, checkType string, p policy.Policy)

Source from the content-addressed store, hash-verified

334// type of check that was performed. It may also completely change the message
335// with a more helpful one in some cases.
336func wrapCosignErrorMessage(err error, checkType string, p policy.Policy) string {
337 // When NOT using the keyless workflow, the "no matching signatures" error from cosign lacks
338 // any useful information. Only in such case, change the error message to something more
339 // helpful.
340 if p == nil || !p.Keyless() {
341 switch err.(type) {
342 case *cosign.ErrNoMatchingSignatures:
343 return fmt.Sprintf(missingSignatureMessage, err)
344 case *cosign.ErrNoMatchingAttestations:
345 return fmt.Sprintf(missingAttestationMessage, err)
346 }
347 }
348 return fmt.Sprintf("Image %s check failed: %s", checkType, err)
349}

Calls 1

KeylessMethod · 0.65

Tested by

no test coverage detected