diff --git a/cmd/cosign/cli/load.go b/cmd/cosign/cli/load.go index 3a04ec19ef1..b8249450948 100644 --- a/cmd/cosign/cli/load.go +++ b/cmd/cosign/cli/load.go @@ -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" ) @@ -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) @@ -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...) } diff --git a/cmd/cosign/cli/options/load.go b/cmd/cosign/cli/options/load.go index 96c7b4a9566..167361d087e 100644 --- a/cmd/cosign/cli/options/load.go +++ b/cmd/cosign/cli/options/load.go @@ -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{}) diff --git a/doc/cosign_load.md b/doc/cosign_load.md index 97fa7142a2b..a69f90be675 100644 --- a/doc/cosign_load.md +++ b/doc/cosign_load.md @@ -19,8 +19,12 @@ cosign load [flags] ### Options ``` - --dir string path to directory where the signed image is stored on disk - -h, --help help for load + --allow-http-registry whether to allow using HTTP protocol while connecting to registries. Don't use this for anything but testing + --allow-insecure-registry whether to allow insecure connections to registries (e.g., with expired or self-signed TLS certificates). Don't use this for anything but testing + --attachment-tag-prefix [AttachmentTagPrefix]sha256-[TargetImageDigest].[AttachmentName] optional custom prefix to use for attached image tags. Attachment images are tagged as: [AttachmentTagPrefix]sha256-[TargetImageDigest].[AttachmentName] + --dir string path to directory where the signed image is stored on disk + -h, --help help for load + --k8s-keychain whether to use the kubernetes keychain instead of the default keychain (supports workload identity). ``` ### Options inherited from parent commands