Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions internal/cmd/checklevelprov.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ type pushOptions struct {
pushRepositories []string
}

// Repository types supported as push destinations
const (
pushRepoGithub = "github"
pushRepoNote = "note"
)

// Support repository types to push
var supportedPushRepos = []string{"github", "note"}
var supportedPushRepos = []string{pushRepoGithub, pushRepoNote}

// Validate checks the push options
func (po *pushOptions) Validate() error {
Expand Down Expand Up @@ -68,6 +74,7 @@ func (clp *checkLevelProvOpts) Validate() error {
return errors.Join([]error{
clp.revisionOpts.Validate(),
clp.verifierOptions.Validate(),
clp.pushOptions.Validate(),
}...)
}

Expand Down Expand Up @@ -122,6 +129,10 @@ and pushed to its remote (--push=note).
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
if err := opts.Validate(); err != nil {
return fmt.Errorf("validating options: %w", err)
}

// Here we need to translate the CLI options to the sourcetool
// options. Some of these will be deprecated as some point for
// a more concise options set.
Expand All @@ -137,14 +148,15 @@ and pushed to its remote (--push=note).
}

var githubStorer, notesStorer, pushAttestations bool
switch {
case slices.Contains(opts.pushLocation, "github"):
if slices.Contains(opts.pushLocation, pushRepoGithub) {
pushAttestations = true
githubStorer = true
case slices.Contains(opts.pushLocation, "notes"):
}
if slices.Contains(opts.pushLocation, pushRepoNote) {
pushAttestations = true
notesStorer = true
case len(opts.pushRepositories) > 0:
}
if len(opts.pushRepositories) > 0 {
pushAttestations = true
}

Expand Down
14 changes: 10 additions & 4 deletions internal/cmd/checktag.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (cto *checkTagOptions) Validate() error {
errs := []error{
cto.revisionOpts.Validate(),
cto.verifierOptions.Validate(),
cto.pushOptions.Validate(),
}
return errors.Join(errs...)
}
Expand Down Expand Up @@ -74,6 +75,10 @@ func addCheckTag(parentCmd *cobra.Command) {
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
if err := opts.Validate(); err != nil {
return fmt.Errorf("validating options: %w", err)
}

// Here we need to translate the CLI options to the sourcetool
// options. Some of these will be deprecated as some point for
// a more concise options set.
Expand All @@ -89,14 +94,15 @@ func addCheckTag(parentCmd *cobra.Command) {
}

var githubStorer, notesStorer, pushAttestations bool
switch {
case slices.Contains(opts.pushLocation, "github"):
if slices.Contains(opts.pushLocation, pushRepoGithub) {
pushAttestations = true
githubStorer = true
case slices.Contains(opts.pushLocation, "notes"):
}
if slices.Contains(opts.pushLocation, pushRepoNote) {
pushAttestations = true
notesStorer = true
case len(opts.pushRepositories) > 0:
}
if len(opts.pushRepositories) > 0 {
pushAttestations = true
}

Expand Down
Loading