Skip to content

Commit

Permalink
Merge branch 'main' into feat/slsa3fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon committed Aug 16, 2022
2 parents 3d882d8 + 6001571 commit 61eac62
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 32 deletions.
1 change: 0 additions & 1 deletion options/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func (o *Options) AddFlags(cmd *cobra.Command) {
"local folder to check",
)

// TODO(v5): Should this be behind a feature flag?
cmd.Flags().StringVar(
&o.Commit,
FlagCommit,
Expand Down
33 changes: 5 additions & 28 deletions options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type Options struct {

// Feature flags.
EnableSarif bool `env:"ENABLE_SARIF"`
EnableScorecardV5 bool `env:"SCORECARD_V5"`
EnableScorecardV6 bool `env:"SCORECARD_V6"`
}

Expand Down Expand Up @@ -91,9 +90,6 @@ const (
// EnvVarEnableSarif is the environment variable which controls enabling
// SARIF logging.
EnvVarEnableSarif = "ENABLE_SARIF"
// EnvVarScorecardV5 is the environment variable which enables scorecard v5
// options.
EnvVarScorecardV5 = "SCORECARD_V5"
// EnvVarScorecardV6 is the environment variable which enables scorecard v6
// options.
EnvVarScorecardV6 = "SCORECARD_V6"
Expand All @@ -103,12 +99,11 @@ var (
// DefaultLogLevel retrieves the default log level.
DefaultLogLevel = log.DefaultLevel.String()

errCommitIsEmpty = errors.New("commit should be non-empty")
errCommitOptionNotSupported = errors.New("commit option is not supported yet")
errFormatNotSupported = errors.New("unsupported format")
errPolicyFileNotSupported = errors.New("policy file is not supported yet")
errRawOptionNotSupported = errors.New("raw option is not supported yet")
errRepoOptionMustBeSet = errors.New(
errCommitIsEmpty = errors.New("commit should be non-empty")
errFormatNotSupported = errors.New("unsupported format")
errPolicyFileNotSupported = errors.New("policy file is not supported yet")
errRawOptionNotSupported = errors.New("raw option is not supported yet")
errRepoOptionMustBeSet = errors.New(
"exactly one of `repo`, `npm`, `pypi`, `rubygems` or `local` must be set",
)
errSARIFNotSupported = errors.New("SARIF format is not supported yet")
Expand Down Expand Up @@ -148,11 +143,6 @@ func (o *Options) Validate() error {
}
}

// Validate V5 features are flag-guarded.
if !o.isV5Enabled() { //nolint:staticcheck
// TODO(v5): Populate v5 feature flags.
}

// Validate V6 features are flag-guarded.
if !o.isV6Enabled() {
if o.Format == FormatRaw {
Expand All @@ -161,12 +151,6 @@ func (o *Options) Validate() error {
errRawOptionNotSupported,
)
}
if o.Commit != clients.HeadSHA {
errs = append(
errs,
errCommitOptionNotSupported,
)
}
}

// Validate format.
Expand Down Expand Up @@ -216,13 +200,6 @@ func (o *Options) isSarifEnabled() bool {
return o.EnableSarif || enabled
}

// isV5Enabled returns true if v5 functionality was specified in options or via
// environment variable.
func (o *Options) isV5Enabled() bool {
_, enabled := os.LookupEnv(EnvVarScorecardV5)
return o.EnableScorecardV5 || enabled
}

// isV6Enabled returns true if v6 functionality was specified in options or via
// environment variable.
func (o *Options) isV6Enabled() bool {
Expand Down
4 changes: 1 addition & 3 deletions options/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

// Cannot run parallel tests because of the ENV variables.
//nolint
// nolint
func TestOptions_Validate(t *testing.T) {
type fields struct {
Repo string
Expand All @@ -38,7 +38,6 @@ func TestOptions_Validate(t *testing.T) {
Metadata []string
ShowDetails bool
EnableSarif bool
EnableScorecardV5 bool
EnableScorecardV6 bool
}
tests := []struct {
Expand Down Expand Up @@ -106,7 +105,6 @@ func TestOptions_Validate(t *testing.T) {
Metadata: tt.fields.Metadata,
ShowDetails: tt.fields.ShowDetails,
EnableSarif: tt.fields.EnableSarif,
EnableScorecardV5: tt.fields.EnableScorecardV5,
EnableScorecardV6: tt.fields.EnableScorecardV6,
}
if o.EnableSarif {
Expand Down

0 comments on commit 61eac62

Please sign in to comment.