Verify verifies an image using a verifier and options provided in options.
(ctx context.Context, rawRef string, hostsDirs []string, experimental bool, options types.ImageVerifyOptions)
| 54 | |
| 55 | // Verify verifies an image using a verifier and options provided in options. |
| 56 | func Verify(ctx context.Context, rawRef string, hostsDirs []string, experimental bool, options types.ImageVerifyOptions) (ref string, err error) { |
| 57 | switch options.Provider { |
| 58 | case "cosign": |
| 59 | if !experimental { |
| 60 | return "", fmt.Errorf("cosign only work with enable experimental feature") |
| 61 | } |
| 62 | |
| 63 | if ref, err = VerifyCosign(ctx, rawRef, options.CosignKey, hostsDirs, options.CosignCertificateIdentity, options.CosignCertificateIdentityRegexp, options.CosignCertificateOidcIssuer, options.CosignCertificateOidcIssuerRegexp); err != nil { |
| 64 | return "", err |
| 65 | } |
| 66 | case "notation": |
| 67 | if !experimental { |
| 68 | return "", fmt.Errorf("notation only work with enable experimental feature") |
| 69 | } |
| 70 | |
| 71 | if ref, err = VerifyNotation(ctx, rawRef, hostsDirs); err != nil { |
| 72 | return "", err |
| 73 | } |
| 74 | case "", "none": |
| 75 | ref = rawRef |
| 76 | log.G(ctx).Debugf("verifying process skipped") |
| 77 | default: |
| 78 | return "", fmt.Errorf("no verifiers found: %s", options.Provider) |
| 79 | } |
| 80 | return ref, nil |
| 81 | } |
no test coverage detected
searching dependent graphs…