Skip to content

Commit

Permalink
minor: supply ShouldUploadToTlog with context (#1104)
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Sanders <[email protected]>
  • Loading branch information
Jake Sanders committed Nov 24, 2021
1 parent 690853e commit fcc8256
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/cosign/cli/attest/attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func AttestCmd(ctx context.Context, ko sign.KeyOpts, regOpts options.RegistryOpt
}

// Check whether we should be uploading to the transparency log
if sign.ShouldUploadToTlog(digest, force, ko.RekorURL) {
if sign.ShouldUploadToTlog(ctx, digest, force, ko.RekorURL) {
bundle, err := sign.UploadToTlog(ctx, sv, ko.RekorURL, func(r *client.Rekor, b []byte) (*models.LogEntryAnon, error) {
return cosign.TLogUploadInTotoAttestation(r, signedPayload, b, timeout)
})
Expand Down
6 changes: 3 additions & 3 deletions cmd/cosign/cli/sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import (
sigPayload "github.com/sigstore/sigstore/pkg/signature/payload"
)

func ShouldUploadToTlog(ref name.Reference, force bool, url string) bool {
func ShouldUploadToTlog(ctx context.Context, ref name.Reference, force bool, url string) bool {
// Check whether experimental is on!
if !options.EnableExperimental() {
return false
Expand All @@ -71,7 +71,7 @@ func ShouldUploadToTlog(ref name.Reference, force bool, url string) bool {
}

// Check if the image is public (no auth in Get)
if _, err := remote.Get(ref); err != nil {
if _, err := remote.Get(ref, remote.WithContext(ctx)); err != nil {
fmt.Fprintf(os.Stderr, "warning: uploading to the transparency log at %s for a private image, please confirm [Y/N]: ", url)

var tlogConfirmResponse string
Expand Down Expand Up @@ -250,7 +250,7 @@ func signDigest(ctx context.Context, digest name.Digest, payload []byte, ko KeyO
if sv.Cert != nil {
opts = append(opts, static.WithCertChain(sv.Cert, sv.Chain))
}
if ShouldUploadToTlog(digest, force, ko.RekorURL) {
if ShouldUploadToTlog(ctx, digest, force, ko.RekorURL) {
bundle, err := UploadToTlog(ctx, sv, ko.RekorURL, func(r *rekGenClient.Rekor, b []byte) (*models.LogEntryAnon, error) {
// TODO - Defaulting the timeout to zero as the CLI doesn't accept timeout.
return cosign.TLogUpload(r, signature, payload, b, time.Duration(0))
Expand Down

0 comments on commit fcc8256

Please sign in to comment.