Skip to content

Commit

Permalink
Rename sugar properties
Browse files Browse the repository at this point in the history
- NamespaceSugarSelector -> NamespaceSelector
- namespace-sugar-selector -> namespace-selector
- TriggerSugarSelector -> TriggerSelector
- trigger-sugar-selector -> trigger-selector
  • Loading branch information
xtreme-sameer-vohra committed Apr 1, 2022
1 parent 0802610 commit 0127894
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
14 changes: 7 additions & 7 deletions config/core/configmaps/sugar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
################################
Expand All @@ -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: {}
8 changes: 4 additions & 4 deletions pkg/apis/sugar/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions pkg/apis/sugar/sugar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/sugar/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/sugar/namespace/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/sugar/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/sugar/trigger/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions test/config/configmaps/config-sugar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit 0127894

Please sign in to comment.