Skip to content

Commit bea8772

Browse files
committed
remove argument
1 parent 7ed2d9e commit bea8772

File tree

7 files changed

+39
-51
lines changed

7 files changed

+39
-51
lines changed

cmd/olm/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ var (
6969

7070
namespace = pflag.String(
7171
"namespace", "", "namespace where cleanup runs")
72-
73-
disableCopiedCSVs = pflag.Bool(
74-
"disableCopiedCSVs", false, "disables copied CSVs in AllNamespace mode when enabled")
7572
)
7673

7774
func init() {
@@ -165,7 +162,6 @@ func main() {
165162
olm.WithOperatorClient(opClient),
166163
olm.WithRestConfig(config),
167164
olm.WithConfigClient(versionedConfigClient),
168-
olm.WithCopiedCSVs(!*disableCopiedCSVs),
169165
)
170166
if err != nil {
171167
logger.WithError(err).Fatalf("error configuring operator")

pkg/controller/operators/olm/config.go

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ import (
2121
type OperatorOption func(*operatorConfig)
2222

2323
type operatorConfig struct {
24-
resyncPeriod func() time.Duration
25-
operatorNamespace string
26-
watchedNamespaces []string
27-
clock utilclock.Clock
28-
logger *logrus.Logger
29-
operatorClient operatorclient.ClientInterface
30-
externalClient versioned.Interface
31-
strategyResolver install.StrategyResolverInterface
32-
apiReconciler APIIntersectionReconciler
33-
apiLabeler labeler.Labeler
34-
restConfig *rest.Config
35-
configClient configv1client.Interface
36-
isCopiedCSVsEnabled bool
24+
resyncPeriod func() time.Duration
25+
operatorNamespace string
26+
watchedNamespaces []string
27+
clock utilclock.Clock
28+
logger *logrus.Logger
29+
operatorClient operatorclient.ClientInterface
30+
externalClient versioned.Interface
31+
strategyResolver install.StrategyResolverInterface
32+
apiReconciler APIIntersectionReconciler
33+
apiLabeler labeler.Labeler
34+
restConfig *rest.Config
35+
configClient configv1client.Interface
3736
}
3837

3938
func (o *operatorConfig) apply(options []OperatorOption) {
@@ -113,12 +112,6 @@ func WithLogger(logger *logrus.Logger) OperatorOption {
113112
}
114113
}
115114

116-
func WithCopiedCSVs(enabled bool) OperatorOption {
117-
return func(config *operatorConfig) {
118-
config.isCopiedCSVsEnabled = enabled
119-
}
120-
}
121-
122115
func WithClock(clock utilclock.Clock) OperatorOption {
123116
return func(config *operatorConfig) {
124117
config.clock = clock

pkg/controller/operators/olm/operator.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ type Operator struct {
9191
clientAttenuator *scoped.ClientAttenuator
9292
serviceAccountQuerier *scoped.UserDefinedServiceAccountQuerier
9393
clientFactory clients.Factory
94-
isCopiedCSVsEnabled bool
9594
}
9695

9796
func NewOperator(ctx context.Context, options ...OperatorOption) (*Operator, error) {
@@ -147,7 +146,6 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
147146
clientAttenuator: scoped.NewClientAttenuator(config.logger, config.restConfig, config.operatorClient),
148147
serviceAccountQuerier: scoped.NewUserDefinedServiceAccountQuerier(config.logger, config.externalClient),
149148
clientFactory: clients.NewFactory(config.restConfig),
150-
isCopiedCSVsEnabled: config.isCopiedCSVsEnabled,
151149
}
152150

153151
// Set up syncing for namespace-scoped resources
@@ -1247,14 +1245,14 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
12471245
"targetNamespaces": strings.Join(operatorGroup.Status.Namespaces, ","),
12481246
}).Debug("copying csv to targets")
12491247

1250-
isCSVCopyingEnabled, err := a.isCSVCopyingEnabled()
1248+
copiedCSVsAreEnabled, err := a.copiedCSVsAreEnabled()
12511249
if err != nil {
12521250
return err
12531251
}
12541252

12551253
// Check if we need to do any copying / annotation for the operatorgroup
12561254
namespaceSet := NewNamespaceSet(operatorGroup.Status.Namespaces)
1257-
if isCSVCopyingEnabled || !namespaceSet.IsAllNamespaces() {
1255+
if copiedCSVsAreEnabled || !namespaceSet.IsAllNamespaces() {
12581256
if err := a.ensureCSVsInNamespaces(clusterServiceVersion, operatorGroup, namespaceSet); err != nil {
12591257
logger.WithError(err).Info("couldn't copy CSV to target namespaces")
12601258
syncError = err
@@ -1294,7 +1292,7 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
12941292
return
12951293
}
12961294

1297-
// isCSVCopyingEnabled determines if csv copying is enabled for OLM.
1295+
// copiedCSVsAreEnabled determines if csv copying is enabled for OLM.
12981296
//
12991297
// This method will first attempt to get the "cluster" olmConfig resource,
13001298
// if any error other than "IsNotFound" is encountered, false and the error
@@ -1304,10 +1302,9 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
13041302
// olmConfig.spec.features.disableCopiedCSVs will be returned along with a
13051303
// nil error.
13061304
//
1307-
// If the "cluster" olmConfig resource is not found, the value will match
1308-
// the value of the disableCopiedCSVs flag provided to OLM on startup will
1309-
// be returned along with a nil error.
1310-
func (a *Operator) isCSVCopyingEnabled() (bool, error) {
1305+
// If the "cluster" olmConfig resource is not found, true will be returned
1306+
// without an error.
1307+
func (a *Operator) copiedCSVsAreEnabled() (bool, error) {
13111308
olmConfig, err := a.client.OperatorsV1().OLMConfigs().Get(context.TODO(), "cluster", metav1.GetOptions{})
13121309
// If there was an error that wasn't an IsNotFound, return the error
13131310
if err != nil && !k8serrors.IsNotFound(err) {
@@ -1316,11 +1313,11 @@ func (a *Operator) isCSVCopyingEnabled() (bool, error) {
13161313

13171314
// If there was no error, return value based on olmConfig ingleton
13181315
if err == nil {
1319-
return olmConfig.IsCopiedCSVsEnabled(), nil
1316+
return olmConfig.CopiedCSVsAreEnabled(), nil
13201317
}
13211318

1322-
// Default to flag if olmConfig cannot be found
1323-
return a.isCopiedCSVsEnabled, nil
1319+
// Default to true if olmConfig cannot be found
1320+
return true, nil
13241321
}
13251322

13261323
func (a *Operator) getCopiedCSVDisabledEventsForCSV(csv *v1alpha1.ClusterServiceVersion) ([]corev1.Event, error) {

vendor/github.com/operator-framework/api/crds/operators.coreos.com_olmconfigs.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)