// Exec runs the verification command
Exec runs the verification command
// Exec runs the verification command
func (c *VerifyCommand) Exec(ctx context.Context, args []string) error {
	if len(args) != 1 {
		return flag.ErrHelp
	}
	if c.Key != "" && c.KmsVal != "" {
		return &KeyParseError{}
	}
	co := cosign.CheckOpts{
		Annotations: *c.Annotations,
		Claims:      c.CheckClaims,
		Tlog:        cosign.Experimental(),
		Roots:       fulcio.Roots,
	}
	pubKeyDescriptor := c.Key
	if c.KmsVal != "" {
		pubKeyDescriptor = c.KmsVal
	}
	if pubKeyDescriptor != "" {
		pubKey, err := cosign.LoadPublicKey(pubKeyDescriptor)
		if err != nil {
			return errors.Wrap(err, "loading public key")
		}
		co.PubKey = pubKey
	}
	imageRef := args[0]
	ref, err := name.ParseReference(imageRef)
	if err != nil {
		return err
	}
	verified, err := cosign.Verify(ctx, ref, co)
	if err != nil {
		return err
	}
	printVerification(verified, co)
	return nil
}
func ( c * VerifyCommand ) Exec ( ctx context . Context , args [ ] string ) error { if len ( args ) != 1 { return flag . ErrHelp } if c . Key != " " && c . KmsVal != " " { return & KeyParseError { } } co := cosign . CheckOpts { Annotations : * c . Annotations , Claims : c . CheckClaims , Tlog : cosign . Experimental ( ) , Roots : fulcio . Roots , } pubKeyDescriptor := c . Key if c . KmsVal != " " { pubKeyDescriptor = c . KmsVal } if pubKeyDescriptor != " " { pubKey , err := cosign . LoadPublicKey ( pubKeyDescriptor ) if err != nil { return errors . Wrap ( err , " " ) } co . PubKey = pubKey } imageRef := args [ 0 ] ref , err := name . ParseReference ( imageRef ) if err != nil { return err } verified , err := cosign . Verify ( ctx , ref , co ) if err != nil { return err } printVerification ( verified , co ) return nil }
Exec runs the verification command
Exec runs the verification command
// Keys are optional!