Skip to content

Commit

Permalink
added extended attribute getter for notation-go (notaryproject#46)
Browse files Browse the repository at this point in the history
* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
  • Loading branch information
patrickzheng200 authored and JeyJeyGao committed Sep 13, 2022
1 parent 9dcfa2b commit 91bf816
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions signature/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package signature

import (
"crypto/x509"
"errors"
"time"
)

Expand Down Expand Up @@ -119,3 +120,14 @@ type Payload struct {
// Content contains the raw bytes of the payload.
Content []byte
}

// ExtendedAttribute fetches the specified Attribute with provided key from
// signerInfo.SignedAttributes.ExtendedAttributes
func (signerInfo *SignerInfo) ExtendedAttribute(key string) (Attribute, error) {
for _, attr := range signerInfo.SignedAttributes.ExtendedAttributes {
if attr.Key == key {
return attr, nil
}
}
return Attribute{}, errors.New("key not in ExtendedAttributes")
}

0 comments on commit 91bf816

Please sign in to comment.