@@ -91,7 +91,6 @@ type Operator struct {
91
91
clientAttenuator * scoped.ClientAttenuator
92
92
serviceAccountQuerier * scoped.UserDefinedServiceAccountQuerier
93
93
clientFactory clients.Factory
94
- isCopiedCSVsEnabled bool
95
94
}
96
95
97
96
func NewOperator (ctx context.Context , options ... OperatorOption ) (* Operator , error ) {
@@ -147,7 +146,6 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
147
146
clientAttenuator : scoped .NewClientAttenuator (config .logger , config .restConfig , config .operatorClient ),
148
147
serviceAccountQuerier : scoped .NewUserDefinedServiceAccountQuerier (config .logger , config .externalClient ),
149
148
clientFactory : clients .NewFactory (config .restConfig ),
150
- isCopiedCSVsEnabled : config .isCopiedCSVsEnabled ,
151
149
}
152
150
153
151
// Set up syncing for namespace-scoped resources
@@ -1247,14 +1245,14 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
1247
1245
"targetNamespaces" : strings .Join (operatorGroup .Status .Namespaces , "," ),
1248
1246
}).Debug ("copying csv to targets" )
1249
1247
1250
- isCSVCopyingEnabled , err := a .isCSVCopyingEnabled ()
1248
+ copiedCSVsAreEnabled , err := a .copiedCSVsAreEnabled ()
1251
1249
if err != nil {
1252
1250
return err
1253
1251
}
1254
1252
1255
1253
// Check if we need to do any copying / annotation for the operatorgroup
1256
1254
namespaceSet := NewNamespaceSet (operatorGroup .Status .Namespaces )
1257
- if isCSVCopyingEnabled || ! namespaceSet .IsAllNamespaces () {
1255
+ if copiedCSVsAreEnabled || ! namespaceSet .IsAllNamespaces () {
1258
1256
if err := a .ensureCSVsInNamespaces (clusterServiceVersion , operatorGroup , namespaceSet ); err != nil {
1259
1257
logger .WithError (err ).Info ("couldn't copy CSV to target namespaces" )
1260
1258
syncError = err
@@ -1294,7 +1292,7 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
1294
1292
return
1295
1293
}
1296
1294
1297
- // isCSVCopyingEnabled determines if csv copying is enabled for OLM.
1295
+ // copiedCSVsAreEnabled determines if csv copying is enabled for OLM.
1298
1296
//
1299
1297
// This method will first attempt to get the "cluster" olmConfig resource,
1300
1298
// if any error other than "IsNotFound" is encountered, false and the error
@@ -1304,10 +1302,9 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
1304
1302
// olmConfig.spec.features.disableCopiedCSVs will be returned along with a
1305
1303
// nil error.
1306
1304
//
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 ) {
1311
1308
olmConfig , err := a .client .OperatorsV1 ().OLMConfigs ().Get (context .TODO (), "cluster" , metav1.GetOptions {})
1312
1309
// If there was an error that wasn't an IsNotFound, return the error
1313
1310
if err != nil && ! k8serrors .IsNotFound (err ) {
@@ -1316,11 +1313,11 @@ func (a *Operator) isCSVCopyingEnabled() (bool, error) {
1316
1313
1317
1314
// If there was no error, return value based on olmConfig ingleton
1318
1315
if err == nil {
1319
- return olmConfig .IsCopiedCSVsEnabled (), nil
1316
+ return olmConfig .CopiedCSVsAreEnabled (), nil
1320
1317
}
1321
1318
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
1324
1321
}
1325
1322
1326
1323
func (a * Operator ) getCopiedCSVDisabledEventsForCSV (csv * v1alpha1.ClusterServiceVersion ) ([]corev1.Event , error ) {
0 commit comments