Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cmd/notation/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math"

"github.com/notaryproject/notation-go"
"github.com/notaryproject/notation-go/log"
"github.com/notaryproject/notation-go/verifier"
"github.com/notaryproject/notation/internal/cmd"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
Expand Down Expand Up @@ -59,6 +60,7 @@ Example - Verify a signature on an OCI artifact identified by a tag (Notation w
func runVerify(command *cobra.Command, opts *verifyOpts) error {
// set log level
ctx := opts.LoggingFlagOpts.SetLoggerLevel(command.Context())
logger := log.GetLogger(ctx)

// resolve the given reference and set the digest
ref, err := resolveReference(command.Context(), &opts.SecureFlagOpts, opts.reference, func(ref registry.Reference, manifestDesc ocispec.Descriptor) {
Expand Down Expand Up @@ -95,9 +97,10 @@ func runVerify(command *cobra.Command, opts *verifyOpts) error {

// core verify process.
_, outcomes, err := notation.Verify(ctx, verifier, repo, verifyOpts)

// write out
// on failure
if err != nil {
logger.Error(err)
}
// write out on failure
if err != nil || len(outcomes) == 0 {
return fmt.Errorf("signature verification failed for all the signatures associated with %s", ref.String())
}
Expand Down