Skip to content

Commit

Permalink
Feature: adds '--allow-insecure-registry' for cosign load (#3000)
Browse files Browse the repository at this point in the history
* Feature: adds '--allow-insecure-registry' for cosign load

Signed-off-by: Mritunjay <mritunjaysharma394@gmail.com>

* use existing opts to add it

Signed-off-by: Mritunjay <mritunjaysharma394@gmail.com>

---------

Signed-off-by: Mritunjay <mritunjaysharma394@gmail.com>
  • Loading branch information
mritunjaysharma394 authored May 23, 2023
1 parent f21081a commit 0544abd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions cmd/cosign/cli/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import (
"fmt"

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

"github.com/sigstore/cosign/v2/cmd/cosign/cli/options"
"github.com/sigstore/cosign/v2/pkg/oci/layout"
"github.com/sigstore/cosign/v2/pkg/oci/remote"

"github.com/spf13/cobra"
)

Expand All @@ -45,7 +47,7 @@ func Load() *cobra.Command {
return cmd
}

func LoadCmd(_ context.Context, opts options.LoadOptions, imageRef string) error {
func LoadCmd(ctx context.Context, opts options.LoadOptions, imageRef string) error {
ref, err := name.ParseReference(imageRef)
if err != nil {
return fmt.Errorf("parsing image name %s: %w", imageRef, err)
Expand All @@ -56,5 +58,11 @@ func LoadCmd(_ context.Context, opts options.LoadOptions, imageRef string) error
if err != nil {
return fmt.Errorf("signed image index: %w", err)
}
return remote.WriteSignedImageIndexImages(ref, sii)

ociremoteOpts, err := opts.Registry.ClientOpts(ctx)
if err != nil {
return err
}

return remote.WriteSignedImageIndexImages(ref, sii, ociremoteOpts...)
}
2 changes: 2 additions & 0 deletions cmd/cosign/cli/options/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import (
// LoadOptions is the top level wrapper for the load command.
type LoadOptions struct {
Directory string
Registry RegistryOptions
}

var _ Interface = (*LoadOptions)(nil)

// AddFlags implements Interface
func (o *LoadOptions) AddFlags(cmd *cobra.Command) {
o.Registry.AddFlags(cmd)
cmd.Flags().StringVar(&o.Directory, "dir", "",
"path to directory where the signed image is stored on disk")
_ = cmd.Flags().SetAnnotation("dir", cobra.BashCompSubdirsInDir, []string{})
Expand Down
8 changes: 6 additions & 2 deletions doc/cosign_load.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0544abd

Please sign in to comment.