Skip to content

Commit 4ec046f

Browse files
committed
Add disableCopiedCSV flag
1 parent 0f53b16 commit 4ec046f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

cmd/olm/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ 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")
7275
)
7376

7477
func init() {
@@ -162,6 +165,7 @@ func main() {
162165
olm.WithOperatorClient(opClient),
163166
olm.WithRestConfig(config),
164167
olm.WithConfigClient(versionedConfigClient),
168+
olm.WithCopiedCSVs(!*disableCopiedCSVs),
165169
)
166170
if err != nil {
167171
logger.WithError(err).Fatalf("error configuring operator")

pkg/controller/operators/olm/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type operatorConfig struct {
3333
apiLabeler labeler.Labeler
3434
restConfig *rest.Config
3535
configClient configv1client.Interface
36+
copiedCSVs bool
3637
}
3738

3839
func (o *operatorConfig) apply(options []OperatorOption) {
@@ -112,6 +113,12 @@ func WithLogger(logger *logrus.Logger) OperatorOption {
112113
}
113114
}
114115

116+
func WithCopiedCSVs(enabled bool) OperatorOption {
117+
return func(config *operatorConfig) {
118+
config.copiedCSVs = enabled
119+
}
120+
}
121+
115122
func WithClock(clock utilclock.Clock) OperatorOption {
116123
return func(config *operatorConfig) {
117124
config.clock = clock

pkg/controller/operators/olm/operator.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type Operator struct {
8888
clientAttenuator *scoped.ClientAttenuator
8989
serviceAccountQuerier *scoped.UserDefinedServiceAccountQuerier
9090
clientFactory clients.Factory
91+
copiedCSVs bool
9192
}
9293

9394
func NewOperator(ctx context.Context, options ...OperatorOption) (*Operator, error) {
@@ -143,6 +144,7 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
143144
clientAttenuator: scoped.NewClientAttenuator(config.logger, config.restConfig, config.operatorClient),
144145
serviceAccountQuerier: scoped.NewUserDefinedServiceAccountQuerier(config.logger, config.externalClient),
145146
clientFactory: clients.NewFactory(config.restConfig),
147+
copiedCSVs: config.copiedCSVs,
146148
}
147149

148150
// Set up syncing for namespace-scoped resources
@@ -1243,9 +1245,8 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
12431245
}).Debug("copying csv to targets")
12441246

12451247
// Check if we need to do any copying / annotation for the operatorgroup
1246-
copyingCSVs := false // TODO: Request OLMConfig singleton
12471248
namespaceSet := NewNamespaceSet(operatorGroup.Status.Namespaces)
1248-
if copyingCSVs || !namespaceSet.IsAllNamespaces() {
1249+
if a.copiedCSVs || !namespaceSet.IsAllNamespaces() {
12491250
if err := a.ensureCSVsInNamespaces(clusterServiceVersion, operatorGroup, namespaceSet); err != nil {
12501251
logger.WithError(err).Info("couldn't copy CSV to target namespaces")
12511252
syncError = err

0 commit comments

Comments
 (0)