Skip to content

Commit 3a93f15

Browse files
committed
refactor operator newcheck constructor defaults
Signed-off-by: Adam D. Cornett <[email protected]>
1 parent 1cace8c commit 3a93f15

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

cmd/preflight/cmd/defaults.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package cmd
22

33
var (
4-
DefaultLogFile = "preflight.log"
5-
DefaultLogLevel = "info"
6-
DefaultNamespace = "default"
7-
DefaultServiceAccount = "default"
8-
DefaultScorecardWaitTime = "240"
4+
DefaultLogFile = "preflight.log"
5+
DefaultLogLevel = "info"
6+
DefaultNamespace = "default"
7+
DefaultServiceAccount = "default"
98
)

cmd/preflight/cmd/root.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func initConfig(viper *spfviper.Viper) {
8888
viper.SetDefault("serviceaccount", DefaultServiceAccount)
8989

9090
// Set up scorecard wait time default
91-
viper.SetDefault("scorecard_wait_time", DefaultScorecardWaitTime)
91+
viper.SetDefault("scorecard_wait_time", runtime.DefaultScorecardWaitTime)
9292

9393
// Set up csv timout default
9494
viper.SetDefault("csv_timeout", runtime.DefaultCSVTimeout)

internal/policy/operator/deployable_by_olm.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ func (p *DeployableByOlmCheck) initOpenShifeEngine() {
9999
}
100100
}
101101

102-
// WithCSVTimeout overrides the default csvTimeout value, for operators that take
103-
// additional time to install.
102+
// WithCSVTimeout customizes how long to wait for a ClusterServiceVersion to become healthy.
104103
func WithCSVTimeout(csvTimeout time.Duration) Option {
105104
return func(oc *DeployableByOlmCheck) {
106105
oc.csvTimeout = csvTimeout

internal/runtime/defaults.go

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ import "time"
55
var (
66
DefaultCSVTimeout = 180 * time.Second
77
DefaultSubscriptionTimeout = 180 * time.Second
8+
DefaultScorecardWaitTime = "240"
89
)

operator/check_operator.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ import (
1616

1717
type Option = func(*operatorCheck)
1818

19-
// TODO(): replace this value when the default in package cmd is moved to a central location
20-
const defaultScorecardWaitTime = "240"
21-
2219
// NewCheck is a check runner that executes the Operator Policy.
2320
func NewCheck(image, indeximage string, kubeconfig []byte, opts ...Option) *operatorCheck {
2421
c := &operatorCheck{
2522
image: image,
2623
kubeconfig: kubeconfig,
2724
indeximage: indeximage,
28-
scorecardWaitTime: defaultScorecardWaitTime,
25+
scorecardWaitTime: runtime.DefaultScorecardWaitTime,
26+
csvTimeout: runtime.DefaultCSVTimeout,
2927
subscriptionTimeout: runtime.DefaultSubscriptionTimeout,
3028
}
3129

@@ -168,8 +166,7 @@ func WithInsecureConnection() Option {
168166
}
169167
}
170168

171-
// WithCSVTimeout overrides the default csvTimeout value, for operators that take
172-
// additional time to install.
169+
// WithCSVTimeout customizes how long to wait for a ClusterServiceVersion to become healthy.
173170
func WithCSVTimeout(csvTimeout time.Duration) Option {
174171
return func(oc *operatorCheck) {
175172
oc.csvTimeout = csvTimeout

0 commit comments

Comments
 (0)