Skip to content

Commit

Permalink
refactor operator newcheck constructor defaults
Browse files Browse the repository at this point in the history
Signed-off-by: Adam D. Cornett <[email protected]>
  • Loading branch information
acornett21 committed Oct 16, 2024
1 parent 1cace8c commit 3a93f15
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
9 changes: 4 additions & 5 deletions cmd/preflight/cmd/defaults.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package cmd

var (
DefaultLogFile = "preflight.log"
DefaultLogLevel = "info"
DefaultNamespace = "default"
DefaultServiceAccount = "default"
DefaultScorecardWaitTime = "240"
DefaultLogFile = "preflight.log"
DefaultLogLevel = "info"
DefaultNamespace = "default"
DefaultServiceAccount = "default"
)
2 changes: 1 addition & 1 deletion cmd/preflight/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func initConfig(viper *spfviper.Viper) {
viper.SetDefault("serviceaccount", DefaultServiceAccount)

// Set up scorecard wait time default
viper.SetDefault("scorecard_wait_time", DefaultScorecardWaitTime)
viper.SetDefault("scorecard_wait_time", runtime.DefaultScorecardWaitTime)

// Set up csv timout default
viper.SetDefault("csv_timeout", runtime.DefaultCSVTimeout)
Expand Down
3 changes: 1 addition & 2 deletions internal/policy/operator/deployable_by_olm.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ func (p *DeployableByOlmCheck) initOpenShifeEngine() {
}
}

// WithCSVTimeout overrides the default csvTimeout value, for operators that take
// additional time to install.
// WithCSVTimeout customizes how long to wait for a ClusterServiceVersion to become healthy.
func WithCSVTimeout(csvTimeout time.Duration) Option {
return func(oc *DeployableByOlmCheck) {
oc.csvTimeout = csvTimeout
Expand Down
1 change: 1 addition & 0 deletions internal/runtime/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import "time"
var (
DefaultCSVTimeout = 180 * time.Second
DefaultSubscriptionTimeout = 180 * time.Second
DefaultScorecardWaitTime = "240"
)
9 changes: 3 additions & 6 deletions operator/check_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ import (

type Option = func(*operatorCheck)

// TODO(): replace this value when the default in package cmd is moved to a central location
const defaultScorecardWaitTime = "240"

// NewCheck is a check runner that executes the Operator Policy.
func NewCheck(image, indeximage string, kubeconfig []byte, opts ...Option) *operatorCheck {
c := &operatorCheck{
image: image,
kubeconfig: kubeconfig,
indeximage: indeximage,
scorecardWaitTime: defaultScorecardWaitTime,
scorecardWaitTime: runtime.DefaultScorecardWaitTime,
csvTimeout: runtime.DefaultCSVTimeout,
subscriptionTimeout: runtime.DefaultSubscriptionTimeout,
}

Expand Down Expand Up @@ -168,8 +166,7 @@ func WithInsecureConnection() Option {
}
}

// WithCSVTimeout overrides the default csvTimeout value, for operators that take
// additional time to install.
// WithCSVTimeout customizes how long to wait for a ClusterServiceVersion to become healthy.
func WithCSVTimeout(csvTimeout time.Duration) Option {
return func(oc *operatorCheck) {
oc.csvTimeout = csvTimeout
Expand Down

0 comments on commit 3a93f15

Please sign in to comment.