From 231a353156e4441dc413e0c96dd43fd2e60c2bb6 Mon Sep 17 00:00:00 2001 From: Sebastian Widmer Date: Tue, 5 Mar 2024 16:58:56 +0100 Subject: [PATCH] Toggles for user attribute and usage profile features --- main.go | 70 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/main.go b/main.go index 9928013..267bf49 100644 --- a/main.go +++ b/main.go @@ -77,6 +77,10 @@ func main() { flag.IntVar(&qps, "qps", 20, "QPS to use for the controller-runtime client") flag.IntVar(&burst, "burst", 100, "Burst to use for the controller-runtime client") + var disableUserAttributeSync, disableUsageProfiles bool + flag.BoolVar(&disableUserAttributeSync, "disable-user-attribute-sync", false, "Disable the UserAttributeSync controller") + flag.BoolVar(&disableUsageProfiles, "disable-usage-profiles", false, "Disable the UsageProfile controllers") + opts := zap.Options{} opts.BindFlags(flag.CommandLine) flag.Parse() @@ -146,42 +150,46 @@ func main() { registerRatioController(mgr, conf, conf.OrganizationLabel) registerOrganizationRBACController(mgr, conf.OrganizationLabel, conf.DefaultOrganizationClusterRoles) - if err := (&controllers.UserAttributeSyncReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Recorder: mgr.GetEventRecorderFor("user-attribute-sync-controller"), + if !disableUserAttributeSync { + if err := (&controllers.UserAttributeSyncReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Recorder: mgr.GetEventRecorderFor("user-attribute-sync-controller"), - ForeignClient: controlAPICluster.GetClient(), - }).SetupWithManagerAndForeignCluster(mgr, controlAPICluster); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "UserAttributeSync") - os.Exit(1) + ForeignClient: controlAPICluster.GetClient(), + }).SetupWithManagerAndForeignCluster(mgr, controlAPICluster); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "UserAttributeSync") + os.Exit(1) + } } - if err := (&controllers.ZoneUsageProfileSyncReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Recorder: mgr.GetEventRecorderFor("usage-profile-sync-controller"), + if !disableUsageProfiles { + if err := (&controllers.ZoneUsageProfileSyncReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Recorder: mgr.GetEventRecorderFor("usage-profile-sync-controller"), - ForeignClient: controlAPICluster.GetClient(), - }).SetupWithManagerAndForeignCluster(mgr, controlAPICluster); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "ratio") - os.Exit(1) - } - if err := (&controllers.ZoneUsageProfileApplyReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Recorder: mgr.GetEventRecorderFor("usage-profile-apply-controller"), - Cache: mgr.GetCache(), - - OrganizationLabel: conf.OrganizationLabel, - Transformers: []transformers.Transformer{ - transformers.NewResourceQuotaTransformer("resourcequota.appuio.io"), - }, + ForeignClient: controlAPICluster.GetClient(), + }).SetupWithManagerAndForeignCluster(mgr, controlAPICluster); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "ratio") + os.Exit(1) + } + if err := (&controllers.ZoneUsageProfileApplyReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Recorder: mgr.GetEventRecorderFor("usage-profile-apply-controller"), + Cache: mgr.GetCache(), + + OrganizationLabel: conf.OrganizationLabel, + Transformers: []transformers.Transformer{ + transformers.NewResourceQuotaTransformer("resourcequota.appuio.io"), + }, - SelectedProfile: selectedUsageProfile, - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "ratio") - os.Exit(1) + SelectedProfile: selectedUsageProfile, + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "ratio") + os.Exit(1) + } } psk := &skipper.PrivilegedUserSkipper{