Skip to content

Commit

Permalink
Don't ignore the media type flag to upload-blob! (#910)
Browse files Browse the repository at this point in the history
Fixes #906

Signed-off-by: Dan Lorenc <[email protected]>
  • Loading branch information
dlorenc authored Oct 19, 2021
1 parent 0bab648 commit dcfb11d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/cosign/cli/upload/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,28 @@ import (
"os"

"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/types"

"github.com/sigstore/cosign/cmd/cosign/cli/options"
cremote "github.com/sigstore/cosign/pkg/cosign/remote"
)

func BlobCmd(ctx context.Context, regOpts options.RegistryOptions, files []cremote.File, contentType, imageRef string) error {
// TODO: use contentType.
ref, err := name.ParseReference(imageRef)
if err != nil {
return err
}

dgstAddr, err := cremote.UploadFiles(ref, files, cremote.DefaultMediaTypeGetter, regOpts.GetRegistryClientOpts(ctx)...)
// We normally discover the content media type by inspecting the byte stream.
// Just pass it directly if it's set on the command line.
mt := cremote.DefaultMediaTypeGetter
if contentType != "" {
mt = func(_ []byte) types.MediaType {
return types.MediaType(contentType)
}
}

dgstAddr, err := cremote.UploadFiles(ref, files, mt, regOpts.GetRegistryClientOpts(ctx)...)
if err != nil {
return err
}
Expand Down

0 comments on commit dcfb11d

Please sign in to comment.