From c8e51d783c21a8758a82f93fd6205d80ee5ddaf1 Mon Sep 17 00:00:00 2001 From: Sameer Vohra Date: Thu, 31 Mar 2022 17:19:35 -0500 Subject: [PATCH] Rename sugar properties - NamespaceSugarSelector -> NamespaceSelector - namespace-sugar-selector -> namespace-selector - TriggerSugarSelector -> TriggerSelector - trigger-sugar-selector -> trigger-selector --- config/core/configmaps/sugar.yaml | 14 ++++++------- pkg/apis/sugar/store.go | 8 ++++---- pkg/apis/sugar/sugar.go | 12 +++++------ pkg/reconciler/sugar/namespace/namespace.go | 2 +- .../sugar/namespace/namespace_test.go | 4 ++-- pkg/reconciler/sugar/trigger/trigger.go | 2 +- pkg/reconciler/sugar/trigger/trigger_test.go | 4 ++-- test/config/configmaps/config-sugar.yaml | 20 +++++++++---------- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/config/core/configmaps/sugar.yaml b/config/core/configmaps/sugar.yaml index f8c2b94bb1b..77fd3a87615 100644 --- a/config/core/configmaps/sugar.yaml +++ b/config/core/configmaps/sugar.yaml @@ -22,7 +22,7 @@ metadata: app.kubernetes.io/version: devel app.kubernetes.io/name: knative-eventing annotations: - knative.dev/example-checksum: "2f817977" + knative.dev/example-checksum: "b05e6e70" data: _example: | ################################ @@ -39,18 +39,18 @@ data: # this example block and unindented to be in the data block # to actually change the configuration. - # namespace-sugar-selector specifies a LabelSelector which + # namespace-selector specifies a LabelSelector which # determines which namespaces the Sugar Controller should operate upon # Use an empty value to disable the feature (this is the default): - namespace-sugar-selector: "" + namespace-selector: "" # Use an empty object to enable for all namespaces - namespace-sugar-selector: {} + namespace-selector: {} - # trigger-sugar-selector specifies a LabelSelector which + # trigger-selector specifies a LabelSelector which # determines which triggers the Sugar Controller should operate upon # Use an empty value to disable the feature (this is the default): - trigger-sugar-selector: "" + trigger-selector: "" # Use an empty object to enable for all triggers - trigger-sugar-selector: {} + trigger-selector: {} diff --git a/pkg/apis/sugar/store.go b/pkg/apis/sugar/store.go index b25bc960029..e5d7dc85bf0 100644 --- a/pkg/apis/sugar/store.go +++ b/pkg/apis/sugar/store.go @@ -30,13 +30,13 @@ const ConfigName = "config-sugar" // Config holds the collection of configurations that we attach to contexts. type Config struct { - // NamespaceSugarSelector specifies a LabelSelector which + // NamespaceSelector specifies a LabelSelector which // determines which namespaces the Sugar Controller should operate upon - NamespaceSugarSelector *metav1.LabelSelector + NamespaceSelector *metav1.LabelSelector - // TriggerSugarSelector specifies a LabelSelector which + // TriggerSelector specifies a LabelSelector which // determines which triggers the Sugar Controller should operate upon - TriggerSugarSelector *metav1.LabelSelector + TriggerSelector *metav1.LabelSelector } func (c *Config) DeepCopy() *Config { diff --git a/pkg/apis/sugar/sugar.go b/pkg/apis/sugar/sugar.go index 63b21e9cdc5..aa2da7c764d 100644 --- a/pkg/apis/sugar/sugar.go +++ b/pkg/apis/sugar/sugar.go @@ -24,15 +24,15 @@ import ( ) const ( - // NamespaceSugarSelectorKey is the name of the configuration + // NamespaceSelectorKey is the name of the configuration // entry that specifies a LabelSelector to control which namespaces // the Sugar Controller operates on. - NamespaceSugarSelectorKey = "namespace-sugar-selector" + NamespaceSelectorKey = "namespace-selector" - // TriggerSugarSelectorKey is the name of the configuration + // TriggerSelectorKey is the name of the configuration // entry that specifies a LabelSelector to control which triggers // the Sugar Controller operates on. - TriggerSugarSelectorKey = "trigger-sugar-selector" + TriggerSelectorKey = "trigger-selector" ) // NewConfigFromConfigMap creates a Config from the supplied ConfigMap @@ -44,8 +44,8 @@ func NewConfigFromConfigMap(configMap *corev1.ConfigMap) (*Config, error) { func NewConfigFromMap(data map[string]string) (*Config, error) { nc := &Config{} if err := cm.Parse(data, - asLabelSelector(NamespaceSugarSelectorKey, &nc.NamespaceSugarSelector), - asLabelSelector(TriggerSugarSelectorKey, &nc.TriggerSugarSelector), + asLabelSelector(NamespaceSelectorKey, &nc.NamespaceSelector), + asLabelSelector(TriggerSelectorKey, &nc.TriggerSelector), ); err != nil { return nil, err } diff --git a/pkg/reconciler/sugar/namespace/namespace.go b/pkg/reconciler/sugar/namespace/namespace.go index 2e20b74ccab..62032109e6d 100644 --- a/pkg/reconciler/sugar/namespace/namespace.go +++ b/pkg/reconciler/sugar/namespace/namespace.go @@ -52,7 +52,7 @@ var _ namespacereconciler.Interface = (*Reconciler)(nil) func (r *Reconciler) ReconcileKind(ctx context.Context, ns *corev1.Namespace) pkgreconciler.Event { cfg := sugarconfig.FromContext(ctx) - selector, err := metav1.LabelSelectorAsSelector(cfg.NamespaceSugarSelector) + selector, err := metav1.LabelSelectorAsSelector(cfg.NamespaceSelector) if err != nil { return fmt.Errorf("invalid label selector for namespaces: %w", err) } diff --git a/pkg/reconciler/sugar/namespace/namespace_test.go b/pkg/reconciler/sugar/namespace/namespace_test.go index 31bbc48e0e0..f4c61415287 100644 --- a/pkg/reconciler/sugar/namespace/namespace_test.go +++ b/pkg/reconciler/sugar/namespace/namespace_test.go @@ -191,7 +191,7 @@ func TestEnabled(t *testing.T) { sugarCfg := &sugarconfig.Config{} if ls, ok := ctx.Value(sugarConfigContextKey).(*metav1.LabelSelector); ok && ls != nil { - sugarCfg.NamespaceSugarSelector = ls + sugarCfg.NamespaceSelector = ls } return namespacereconciler.NewReconciler(ctx, logger, @@ -280,7 +280,7 @@ func TestDisabled(t *testing.T) { sugarCfg := &sugarconfig.Config{} if ls, ok := ctx.Value(sugarConfigContextKey).(*metav1.LabelSelector); ok && ls != nil { - sugarCfg.NamespaceSugarSelector = ls + sugarCfg.NamespaceSelector = ls } return namespacereconciler.NewReconciler(ctx, logger, diff --git a/pkg/reconciler/sugar/trigger/trigger.go b/pkg/reconciler/sugar/trigger/trigger.go index 38889de80ec..230ee79e70b 100644 --- a/pkg/reconciler/sugar/trigger/trigger.go +++ b/pkg/reconciler/sugar/trigger/trigger.go @@ -53,7 +53,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, t *v1.Trigger) reconcile cfg := sugarconfig.FromContext(ctx) - selector, err := metav1.LabelSelectorAsSelector(cfg.TriggerSugarSelector) + selector, err := metav1.LabelSelectorAsSelector(cfg.TriggerSelector) if err != nil { return fmt.Errorf("invalid label selector for triggers: %w", err) } diff --git a/pkg/reconciler/sugar/trigger/trigger_test.go b/pkg/reconciler/sugar/trigger/trigger_test.go index 1ab23cd0ca8..5ff8b56e6b2 100644 --- a/pkg/reconciler/sugar/trigger/trigger_test.go +++ b/pkg/reconciler/sugar/trigger/trigger_test.go @@ -185,7 +185,7 @@ func TestEnabled(t *testing.T) { sugarCfg := &sugarconfig.Config{} if ls, ok := ctx.Value(sugarConfigContextKey).(*metav1.LabelSelector); ok && ls != nil { - sugarCfg.TriggerSugarSelector = ls + sugarCfg.TriggerSelector = ls } return trigger.NewReconciler(ctx, logger, @@ -265,7 +265,7 @@ func TestDisabled(t *testing.T) { sugarCfg := &sugarconfig.Config{} if ls, ok := ctx.Value(sugarConfigContextKey).(*metav1.LabelSelector); ok && ls != nil { - sugarCfg.TriggerSugarSelector = ls + sugarCfg.TriggerSelector = ls } return trigger.NewReconciler(ctx, logger, diff --git a/test/config/configmaps/config-sugar.yaml b/test/config/configmaps/config-sugar.yaml index 281acb80233..2c72250156a 100644 --- a/test/config/configmaps/config-sugar.yaml +++ b/test/config/configmaps/config-sugar.yaml @@ -22,17 +22,17 @@ metadata: app.kubernetes.io/version: devel app.kubernetes.io/name: knative-eventing data: - # namespace-sugar-selector specifies a LabelSelector which + # namespace-selector specifies a LabelSelector which # determines which namespaces the Sugar Controller should operate upon # # Use an empty value to disable the feature (this is the default): - # namespace-sugar-selector: "" + # namespace-selector: "" # # Use an empty object to enable for all namespaces - # namespace-sugar-selector: {} + # namespace-selector: {} # # Use the following block to replicate the legacy behaviour - # namespace-sugar-selector: | + # namespace-selector: | # matchExpressions: # - key: "eventing.knative.dev/injection" # operator: "In" @@ -41,28 +41,28 @@ data: # Useful labels include the "kubernetes.io/metadata.name" label to # avoid Sugar opearting on "kube-system" namespaces. # - namespace-sugar-selector: | + namespace-selector: | matchExpressions: - key: "e2e.eventing.knative.dev/injection" operator: "In" values: ["enabled"] - # trigger-sugar-selector specifies a LabelSelector which + # trigger-selector specifies a LabelSelector which # determines which triggers the Sugar Controller should operate upon # # Use an empty value to disable the feature (this is the default): - # trigger-sugar-selector: "" + # trigger-selector: "" # # Use an empty object to enable for all triggers - # trigger-sugar-selector: {} + # trigger-selector: {} # # Use the following block to replicate the legacy behaviour - # trigger-sugar-selector: | + # trigger-selector: | # matchExpressions: # - key: "eventing.knative.dev/injection" # operator: "In" # values: ["enabled"] - trigger-sugar-selector: | + trigger-selector: | matchExpressions: - key: "e2e.eventing.knative.dev/injection" operator: "In"