Skip to content

Commit 231a353

Browse files
committed
Toggles for user attribute and usage profile features
1 parent 667e977 commit 231a353

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

main.go

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ func main() {
7777
flag.IntVar(&qps, "qps", 20, "QPS to use for the controller-runtime client")
7878
flag.IntVar(&burst, "burst", 100, "Burst to use for the controller-runtime client")
7979

80+
var disableUserAttributeSync, disableUsageProfiles bool
81+
flag.BoolVar(&disableUserAttributeSync, "disable-user-attribute-sync", false, "Disable the UserAttributeSync controller")
82+
flag.BoolVar(&disableUsageProfiles, "disable-usage-profiles", false, "Disable the UsageProfile controllers")
83+
8084
opts := zap.Options{}
8185
opts.BindFlags(flag.CommandLine)
8286
flag.Parse()
@@ -146,42 +150,46 @@ func main() {
146150
registerRatioController(mgr, conf, conf.OrganizationLabel)
147151
registerOrganizationRBACController(mgr, conf.OrganizationLabel, conf.DefaultOrganizationClusterRoles)
148152

149-
if err := (&controllers.UserAttributeSyncReconciler{
150-
Client: mgr.GetClient(),
151-
Scheme: mgr.GetScheme(),
152-
Recorder: mgr.GetEventRecorderFor("user-attribute-sync-controller"),
153+
if !disableUserAttributeSync {
154+
if err := (&controllers.UserAttributeSyncReconciler{
155+
Client: mgr.GetClient(),
156+
Scheme: mgr.GetScheme(),
157+
Recorder: mgr.GetEventRecorderFor("user-attribute-sync-controller"),
153158

154-
ForeignClient: controlAPICluster.GetClient(),
155-
}).SetupWithManagerAndForeignCluster(mgr, controlAPICluster); err != nil {
156-
setupLog.Error(err, "unable to create controller", "controller", "UserAttributeSync")
157-
os.Exit(1)
159+
ForeignClient: controlAPICluster.GetClient(),
160+
}).SetupWithManagerAndForeignCluster(mgr, controlAPICluster); err != nil {
161+
setupLog.Error(err, "unable to create controller", "controller", "UserAttributeSync")
162+
os.Exit(1)
163+
}
158164
}
159165

160-
if err := (&controllers.ZoneUsageProfileSyncReconciler{
161-
Client: mgr.GetClient(),
162-
Scheme: mgr.GetScheme(),
163-
Recorder: mgr.GetEventRecorderFor("usage-profile-sync-controller"),
166+
if !disableUsageProfiles {
167+
if err := (&controllers.ZoneUsageProfileSyncReconciler{
168+
Client: mgr.GetClient(),
169+
Scheme: mgr.GetScheme(),
170+
Recorder: mgr.GetEventRecorderFor("usage-profile-sync-controller"),
164171

165-
ForeignClient: controlAPICluster.GetClient(),
166-
}).SetupWithManagerAndForeignCluster(mgr, controlAPICluster); err != nil {
167-
setupLog.Error(err, "unable to create controller", "controller", "ratio")
168-
os.Exit(1)
169-
}
170-
if err := (&controllers.ZoneUsageProfileApplyReconciler{
171-
Client: mgr.GetClient(),
172-
Scheme: mgr.GetScheme(),
173-
Recorder: mgr.GetEventRecorderFor("usage-profile-apply-controller"),
174-
Cache: mgr.GetCache(),
175-
176-
OrganizationLabel: conf.OrganizationLabel,
177-
Transformers: []transformers.Transformer{
178-
transformers.NewResourceQuotaTransformer("resourcequota.appuio.io"),
179-
},
172+
ForeignClient: controlAPICluster.GetClient(),
173+
}).SetupWithManagerAndForeignCluster(mgr, controlAPICluster); err != nil {
174+
setupLog.Error(err, "unable to create controller", "controller", "ratio")
175+
os.Exit(1)
176+
}
177+
if err := (&controllers.ZoneUsageProfileApplyReconciler{
178+
Client: mgr.GetClient(),
179+
Scheme: mgr.GetScheme(),
180+
Recorder: mgr.GetEventRecorderFor("usage-profile-apply-controller"),
181+
Cache: mgr.GetCache(),
182+
183+
OrganizationLabel: conf.OrganizationLabel,
184+
Transformers: []transformers.Transformer{
185+
transformers.NewResourceQuotaTransformer("resourcequota.appuio.io"),
186+
},
180187

181-
SelectedProfile: selectedUsageProfile,
182-
}).SetupWithManager(mgr); err != nil {
183-
setupLog.Error(err, "unable to create controller", "controller", "ratio")
184-
os.Exit(1)
188+
SelectedProfile: selectedUsageProfile,
189+
}).SetupWithManager(mgr); err != nil {
190+
setupLog.Error(err, "unable to create controller", "controller", "ratio")
191+
os.Exit(1)
192+
}
185193
}
186194

187195
psk := &skipper.PrivilegedUserSkipper{

0 commit comments

Comments
 (0)