Skip to content

Commit

Permalink
Add String() to print cosign signature details
Browse files Browse the repository at this point in the history
  • Loading branch information
yawangwang committed Oct 13, 2023
1 parent 56211cd commit 8683300
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions launcher/internal/oci/cosign/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type Sig struct {
// Blob represents the opaque data uploaded to OCI registry associated with the layer.
// This contains the Simple Signing Payload as described in https://github.com/sigstore/cosign/blob/main/specs/SIGNATURE_SPEC.md#tag-based-discovery.
Blob []byte
// SourceRepo represents the location that stores this signature.
SourceRepo string
}

// CosignSigKey is the key of the cosign-generated signature embedded in OCI image manifest.
Expand Down Expand Up @@ -68,3 +70,12 @@ func (s Sig) PublicKey() ([]byte, error) {
func (s Sig) SigningAlgorithm() (oci.SigningAlgorithm, error) {
return "", fmt.Errorf("not implemented")
}

// String returns signature details
func (s Sig) String() string {
sig, err := s.Base64Encoded()
if err != nil {
return fmt.Sprintf("[signature error: %s]", err.Error())
}
return fmt.Sprintf("[signature: %q, sourceRepo: %q]", sig, s.SourceRepo)
}
5 changes: 3 additions & 2 deletions launcher/internal/signaturediscovery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ func (c *Client) FetchImageSignatures(ctx context.Context, targetRepository stri
return nil, err
}
sig := &cosign.Sig{
Layer: layer,
Blob: blob,
Layer: layer,
Blob: blob,
SourceRepo: targetRepository,
}
signatures = append(signatures, sig)
}
Expand Down

0 comments on commit 8683300

Please sign in to comment.