Skip to content

Commit

Permalink
Enable fetching signatures without remote get.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaus67 committed May 24, 2023
1 parent 8714480 commit aa1a890
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/cosign/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import (
"context"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"os"
"runtime"
"sync"

"github.com/google/go-containerregistry/pkg/name"
"github.com/sigstore/cosign/v2/pkg/cosign/bundle"
"github.com/sigstore/cosign/v2/pkg/oci"
ociremote "github.com/sigstore/cosign/v2/pkg/oci/remote"
"golang.org/x/sync/errgroup"
)
Expand Down Expand Up @@ -67,8 +69,15 @@ func FetchSignaturesForReference(_ context.Context, ref name.Reference, opts ...
if err != nil {
return nil, err
}
sigs, err := FetchSignatures(simg)
if err != nil {
return nil, fmt.Errorf("%s: %w", ref, err)
}
return sigs, nil
}

sigs, err := simg.Signatures()
func FetchSignatures(se oci.SignedEntity) ([]SignedPayload, error) {
sigs, err := se.Signatures()
if err != nil {
return nil, fmt.Errorf("remote image: %w", err)
}
Expand All @@ -77,7 +86,7 @@ func FetchSignaturesForReference(_ context.Context, ref name.Reference, opts ...
return nil, fmt.Errorf("fetching signatures: %w", err)
}
if len(l) == 0 {
return nil, fmt.Errorf("no signatures associated with %s", ref)
return nil, errors.New("no signatures associated")
}

signatures := make([]SignedPayload, len(l))
Expand Down

0 comments on commit aa1a890

Please sign in to comment.