Skip to content

Commit

Permalink
deprecate COSIGN_REPOSITORY in favor of provenanceRepository
Browse files Browse the repository at this point in the history
Signed-off-by: saisatishkarra <saisatish.karra@konghq.com>
  • Loading branch information
saisatishkarra committed Jan 22, 2024
1 parent 36bf836 commit 93ddb5d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cli/slsa-verifier/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func verifyArtifactCmd() *cobra.Command {
}

func verifyImageCmd() *cobra.Command {
o := &verify.VerifyImageOptions{}
o := &verify.VerifyOptions{}

cmd := &cobra.Command{
Use: "verify-image [flags] image",
Expand Down
26 changes: 6 additions & 20 deletions cli/slsa-verifier/verify/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ type VerifyOptions struct {
BuildWorkflowInputs workflowInputs
BuilderID string
/* Other */
ProvenancePath string
PrintProvenance bool
ProvenancePath string
ProvenanceRepository string
PrintProvenance bool
}

var _ Interface = (*VerifyOptions)(nil)
Expand Down Expand Up @@ -67,31 +68,16 @@ func (o *VerifyOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.ProvenancePath, "provenance-path", "",
"path to a provenance file")

cmd.Flags().StringVar(&o.ProvenanceRepository, "provenance-repository", "",
"image repository for provenance with format: <registry>/<repository>")

cmd.Flags().BoolVar(&o.PrintProvenance, "print-provenance", false,
"[optional] print the verified provenance to stdout")

cmd.MarkFlagRequired("source-uri")
cmd.MarkFlagsMutuallyExclusive("source-versioned-tag", "source-tag")
}

// VerifyImageOptions is the top-level options for the `verifyImage` command

type VerifyImageOptions struct {
VerifyOptions
/* Other */
ProvenanceRepository string
}

var _ Interface = (*VerifyImageOptions)(nil)

// AddFlags implements Interface.
func (o *VerifyImageOptions) AddFlags(cmd *cobra.Command) {
o.VerifyOptions.AddFlags(cmd)

cmd.Flags().StringVar(&o.ProvenanceRepository, "provenance-repository", "",
"image repository for provenance with format: <registry>/<repository>. When set, overrides COSIGN_REPOSITORY environment variable")
}

// VerifyNpmOptions is the top-level options for the `verifyNpmPackage` command.
type VerifyNpmOptions struct {
VerifyOptions
Expand Down
5 changes: 1 addition & 4 deletions cli/slsa-verifier/verify/verify_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ func (c *VerifyImageCommand) Exec(ctx context.Context, artifacts []string) (*uti
}
}

var verifiedProvenance []byte
var outBuilderID *utils.TrustedBuilderID

verifiedProvenance, outBuilderID, err = verifiers.VerifyImage(ctx, artifacts[0], provenance, provenanceOpts, builderOpts)
verifiedProvenance, outBuilderID, err := verifiers.VerifyImage(ctx, artifacts[0], provenance, provenanceOpts, builderOpts)

if err != nil {
return nil, err
Expand Down
8 changes: 1 addition & 7 deletions verifiers/internal/gha/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,11 @@ func (v *GHAVerifier) VerifyImage(ctx context.Context,

var provenanceTargetRepository name.Repository
// Consume input for --provenance-repository when set
if *provenanceOpts.ExpectedProvenanceRepository != "" {
if provenanceOpts.ExpectedProvenanceRepository != nil {
provenanceTargetRepository, err = name.NewRepository(*provenanceOpts.ExpectedProvenanceRepository)
if err != nil {
return nil, nil, err
}
} else {
// If user input --provenance-repository is empty, look for COSIGN_REPOSITORY environment
provenanceTargetRepository, err = ociremote.GetEnvTargetRepository()
if err != nil {
return nil, nil, err
}
}

registryClientOpts := []ociremote.Option{}
Expand Down

0 comments on commit 93ddb5d

Please sign in to comment.