Skip to content

Commit 2ec3f78

Browse files
committed
[refactor] Renaming const prefixing with default
Signed-off-by: dd di cesare <[email protected]>
1 parent 93042c1 commit 2ec3f78

10 files changed

+18
-19
lines changed

internal/controller/auth_policy_status_updater.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func (r *AuthPolicyStatusUpdater) enforcedCondition(policy *kuadrantv1.AuthPolic
224224
// check the status of the gateways' configuration resources
225225
for _, g := range affectedGateways {
226226
switch g.gatewayClass.Spec.ControllerName {
227-
case istioGatewayControllerName:
227+
case defaultIstioGatewayControllerName:
228228
// EnvoyFilter
229229
istioAuthClustersModifiedGateways, _ := state.Load(StateIstioAuthClustersModified)
230230
componentsToSync = append(componentsToSync, gatewayComponentsToSync(g.gateway, kuadrantistio.EnvoyFilterGroupKind, istioAuthClustersModifiedGateways, topology, func(_ machinery.Object) bool {
@@ -237,17 +237,17 @@ func (r *AuthPolicyStatusUpdater) enforcedCondition(policy *kuadrantv1.AuthPolic
237237
// return meta.IsStatusConditionTrue(lo.Map(obj.(*controller.RuntimeObject).Object.(*istioclientgoextensionv1alpha1.WasmPlugin).Status.Conditions, kuadrantistio.ConditionToProperConditionFunc), "Ready")
238238
return true // Istio won't ever populate the status stanza of WasmPlugin resources, so we cannot expect to find a given a condition there
239239
})...)
240-
case envoyGatewayGatewayControllerName:
240+
case defaultEnvoyGatewayGatewayControllerName:
241241
gatewayAncestor := gatewayapiv1.ParentReference{Name: gatewayapiv1.ObjectName(g.gateway.GetName()), Namespace: ptr.To(gatewayapiv1.Namespace(g.gateway.GetNamespace()))}
242242
// EnvoyPatchPolicy
243243
envoyGatewayAuthClustersModifiedGateways, _ := state.Load(StateEnvoyGatewayAuthClustersModified)
244244
componentsToSync = append(componentsToSync, gatewayComponentsToSync(g.gateway, kuadrantenvoygateway.EnvoyPatchPolicyGroupKind, envoyGatewayAuthClustersModifiedGateways, topology, func(obj machinery.Object) bool {
245-
return meta.IsStatusConditionTrue(kuadrantgatewayapi.PolicyStatusConditionsFromAncestor(obj.(*controller.RuntimeObject).Object.(*envoygatewayv1alpha1.EnvoyPatchPolicy).Status, envoyGatewayGatewayControllerName, gatewayAncestor, gatewayapiv1.Namespace(obj.GetNamespace())), string(envoygatewayv1alpha1.PolicyConditionProgrammed))
245+
return meta.IsStatusConditionTrue(kuadrantgatewayapi.PolicyStatusConditionsFromAncestor(obj.(*controller.RuntimeObject).Object.(*envoygatewayv1alpha1.EnvoyPatchPolicy).Status, defaultEnvoyGatewayGatewayControllerName, gatewayAncestor, gatewayapiv1.Namespace(obj.GetNamespace())), string(envoygatewayv1alpha1.PolicyConditionProgrammed))
246246
})...)
247247
// EnvoyExtensionPolicy
248248
envoyGatewayExtensionsModifiedGateways, _ := state.Load(StateEnvoyGatewayExtensionsModified)
249249
componentsToSync = append(componentsToSync, gatewayComponentsToSync(g.gateway, kuadrantenvoygateway.EnvoyExtensionPolicyGroupKind, envoyGatewayExtensionsModifiedGateways, topology, func(obj machinery.Object) bool {
250-
return meta.IsStatusConditionTrue(kuadrantgatewayapi.PolicyStatusConditionsFromAncestor(obj.(*controller.RuntimeObject).Object.(*envoygatewayv1alpha1.EnvoyExtensionPolicy).Status, envoyGatewayGatewayControllerName, gatewayAncestor, gatewayapiv1.Namespace(obj.GetNamespace())), string(gatewayapiv1alpha2.PolicyConditionAccepted))
250+
return meta.IsStatusConditionTrue(kuadrantgatewayapi.PolicyStatusConditionsFromAncestor(obj.(*controller.RuntimeObject).Object.(*envoygatewayv1alpha1.EnvoyExtensionPolicy).Status, defaultEnvoyGatewayGatewayControllerName, gatewayAncestor, gatewayapiv1.Namespace(obj.GetNamespace())), string(gatewayapiv1alpha2.PolicyConditionAccepted))
251251
})...)
252252
default:
253253
componentsToSync = append(componentsToSync, fmt.Sprintf("%s (%s/%s)", machinery.GatewayGroupKind.Kind, g.gateway.GetNamespace(), g.gateway.GetName()))

internal/controller/data_plane_policies_workflow.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ import (
1818
)
1919

2020
const (
21-
// make these configurable?
22-
istioGatewayControllerName = "istio.io/gateway-controller"
23-
envoyGatewayGatewayControllerName = "gateway.envoyproxy.io/gatewayclass-controller"
21+
defaultIstioGatewayControllerName = "istio.io/gateway-controller"
22+
defaultEnvoyGatewayGatewayControllerName = "gateway.envoyproxy.io/gatewayclass-controller"
2423
)
2524

2625
var (

internal/controller/envoy_gateway_auth_cluster_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (r *EnvoyGatewayAuthClusterReconciler) Reconcile(ctx context.Context, _ []c
7474

7575
gateways := lo.UniqBy(lo.FilterMap(lo.Values(effectivePolicies.(EffectiveAuthPolicies)), func(effectivePolicy EffectiveAuthPolicy, _ int) (*machinery.Gateway, bool) {
7676
gatewayClass, gateway, _, _, _, _ := kuadrantpolicymachinery.ObjectsInRequestPath(effectivePolicy.Path)
77-
return gateway, gatewayClass.Spec.ControllerName == envoyGatewayGatewayControllerName
77+
return gateway, gatewayClass.Spec.ControllerName == defaultEnvoyGatewayGatewayControllerName
7878
}), func(gateway *machinery.Gateway) string {
7979
return gateway.GetLocator()
8080
})

internal/controller/envoy_gateway_extension_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func (r *EnvoyGatewayExtensionReconciler) buildWasmConfigs(ctx context.Context,
174174
gatewayClass, gateway, _, _, _, _ := kuadrantpolicymachinery.ObjectsInRequestPath(path)
175175

176176
// ignore if not an envoy gateway gateway
177-
if gatewayClass.Spec.ControllerName != envoyGatewayGatewayControllerName {
177+
if gatewayClass.Spec.ControllerName != defaultEnvoyGatewayGatewayControllerName {
178178
continue
179179
}
180180

internal/controller/envoy_gateway_ratelimit_cluster_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (r *EnvoyGatewayRateLimitClusterReconciler) Reconcile(ctx context.Context,
7474

7575
gateways := lo.UniqBy(lo.FilterMap(lo.Values(effectivePolicies.(EffectiveRateLimitPolicies)), func(effectivePolicy EffectiveRateLimitPolicy, _ int) (*machinery.Gateway, bool) {
7676
gatewayClass, gateway, _, _, _, _ := kuadrantpolicymachinery.ObjectsInRequestPath(effectivePolicy.Path)
77-
return gateway, gatewayClass.Spec.ControllerName == envoyGatewayGatewayControllerName
77+
return gateway, gatewayClass.Spec.ControllerName == defaultEnvoyGatewayGatewayControllerName
7878
}), func(gateway *machinery.Gateway) string {
7979
return gateway.GetLocator()
8080
})

internal/controller/istio_auth_cluster_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (r *IstioAuthClusterReconciler) Reconcile(ctx context.Context, _ []controll
7474

7575
gateways := lo.UniqBy(lo.FilterMap(lo.Values(effectivePolicies.(EffectiveAuthPolicies)), func(effectivePolicy EffectiveAuthPolicy, _ int) (*machinery.Gateway, bool) {
7676
gatewayClass, gateway, _, _, _, _ := kuadrantpolicymachinery.ObjectsInRequestPath(effectivePolicy.Path)
77-
return gateway, gatewayClass.Spec.ControllerName == istioGatewayControllerName
77+
return gateway, gatewayClass.Spec.ControllerName == defaultIstioGatewayControllerName
7878
}), func(gateway *machinery.Gateway) string {
7979
return gateway.GetLocator()
8080
})

internal/controller/istio_extension_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (r *IstioExtensionReconciler) buildWasmConfigs(ctx context.Context, state *
179179
gatewayClass, gateway, _, _, _, _ := kuadrantpolicymachinery.ObjectsInRequestPath(path)
180180

181181
// ignore if not an istio gateway
182-
if gatewayClass.Spec.ControllerName != istioGatewayControllerName {
182+
if gatewayClass.Spec.ControllerName != defaultIstioGatewayControllerName {
183183
continue
184184
}
185185

internal/controller/istio_ratelimit_cluster_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (r *IstioRateLimitClusterReconciler) Reconcile(ctx context.Context, _ []con
7474

7575
gateways := lo.UniqBy(lo.FilterMap(lo.Values(effectivePolicies.(EffectiveRateLimitPolicies)), func(effectivePolicy EffectiveRateLimitPolicy, _ int) (*machinery.Gateway, bool) {
7676
gatewayClass, gateway, _, _, _, _ := kuadrantpolicymachinery.ObjectsInRequestPath(effectivePolicy.Path)
77-
return gateway, gatewayClass.Spec.ControllerName == istioGatewayControllerName
77+
return gateway, gatewayClass.Spec.ControllerName == defaultIstioGatewayControllerName
7878
}), func(gateway *machinery.Gateway) string {
7979
return gateway.GetLocator()
8080
})

internal/controller/observability_reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,15 @@ func (r *ObservabilityReconciler) Reconcile(baseCtx context.Context, _ []control
402402
for _, gatewayClass := range gatewayClasses {
403403
gateways := topology.All().Children(gatewayClass)
404404
gwClass := gatewayClass.(*machinery.GatewayClass)
405-
if gwClass.GatewayClass.Spec.ControllerName == istioGatewayControllerName {
405+
if gwClass.GatewayClass.Spec.ControllerName == defaultIstioGatewayControllerName {
406406
istiodMonitor := istiodMonitorBuild(istiodMonitorNS)
407407
r.createServiceMonitor(ctx, istiodMonitor, logger)
408408

409409
for _, gateway := range gateways {
410410
istioPodMonitor := istioPodMonitorBuild(gateway.GetNamespace())
411411
r.createPodMonitor(ctx, istioPodMonitor, logger)
412412
}
413-
} else if gwClass.GatewayClass.Spec.ControllerName == envoyGatewayGatewayControllerName {
413+
} else if gwClass.GatewayClass.Spec.ControllerName == defaultEnvoyGatewayGatewayControllerName {
414414
envoyGatewayMonitor := envoyGatewayMonitorBuild(envoyGatewayMonitorNS)
415415
r.createServiceMonitor(ctx, envoyGatewayMonitor, logger)
416416

internal/controller/ratelimit_policy_status_updater.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (r *RateLimitPolicyStatusUpdater) enforcedCondition(policy *kuadrantv1.Rate
194194
// check the status of the gateways' configuration resources
195195
for _, g := range affectedGateways {
196196
switch g.gatewayClass.Spec.ControllerName {
197-
case istioGatewayControllerName:
197+
case defaultIstioGatewayControllerName:
198198
// EnvoyFilter
199199
istioRateLimitClustersModifiedGateways, _ := state.Load(StateIstioRateLimitClustersModified)
200200
componentsToSync = append(componentsToSync, gatewayComponentsToSync(g.gateway, kuadrantistio.EnvoyFilterGroupKind, istioRateLimitClustersModifiedGateways, topology, func(_ machinery.Object) bool {
@@ -207,17 +207,17 @@ func (r *RateLimitPolicyStatusUpdater) enforcedCondition(policy *kuadrantv1.Rate
207207
// return meta.IsStatusConditionTrue(lo.Map(obj.(*controller.RuntimeObject).Object.(*istioclientgoextensionv1alpha1.WasmPlugin).Status.Conditions, kuadrantistio.ConditionToProperConditionFunc), "Ready")
208208
return true // Istio won't ever populate the status stanza of WasmPlugin resources, so we cannot expect to find a given a condition there
209209
})...)
210-
case envoyGatewayGatewayControllerName:
210+
case defaultEnvoyGatewayGatewayControllerName:
211211
gatewayAncestor := gatewayapiv1.ParentReference{Name: gatewayapiv1.ObjectName(g.gateway.GetName()), Namespace: ptr.To(gatewayapiv1.Namespace(g.gateway.GetNamespace()))}
212212
// EnvoyPatchPolicy
213213
envoyGatewayRateLimitClustersModifiedGateways, _ := state.Load(StateEnvoyGatewayRateLimitClustersModified)
214214
componentsToSync = append(componentsToSync, gatewayComponentsToSync(g.gateway, kuadrantenvoygateway.EnvoyPatchPolicyGroupKind, envoyGatewayRateLimitClustersModifiedGateways, topology, func(obj machinery.Object) bool {
215-
return meta.IsStatusConditionTrue(kuadrantgatewayapi.PolicyStatusConditionsFromAncestor(obj.(*controller.RuntimeObject).Object.(*envoygatewayv1alpha1.EnvoyPatchPolicy).Status, envoyGatewayGatewayControllerName, gatewayAncestor, gatewayapiv1.Namespace(obj.GetNamespace())), string(envoygatewayv1alpha1.PolicyConditionProgrammed))
215+
return meta.IsStatusConditionTrue(kuadrantgatewayapi.PolicyStatusConditionsFromAncestor(obj.(*controller.RuntimeObject).Object.(*envoygatewayv1alpha1.EnvoyPatchPolicy).Status, defaultEnvoyGatewayGatewayControllerName, gatewayAncestor, gatewayapiv1.Namespace(obj.GetNamespace())), string(envoygatewayv1alpha1.PolicyConditionProgrammed))
216216
})...)
217217
// EnvoyExtensionPolicy
218218
envoyGatewayExtensionsModifiedGateways, _ := state.Load(StateEnvoyGatewayExtensionsModified)
219219
componentsToSync = append(componentsToSync, gatewayComponentsToSync(g.gateway, kuadrantenvoygateway.EnvoyExtensionPolicyGroupKind, envoyGatewayExtensionsModifiedGateways, topology, func(obj machinery.Object) bool {
220-
return meta.IsStatusConditionTrue(kuadrantgatewayapi.PolicyStatusConditionsFromAncestor(obj.(*controller.RuntimeObject).Object.(*envoygatewayv1alpha1.EnvoyExtensionPolicy).Status, envoyGatewayGatewayControllerName, gatewayAncestor, gatewayapiv1.Namespace(obj.GetNamespace())), string(gatewayapiv1alpha2.PolicyConditionAccepted))
220+
return meta.IsStatusConditionTrue(kuadrantgatewayapi.PolicyStatusConditionsFromAncestor(obj.(*controller.RuntimeObject).Object.(*envoygatewayv1alpha1.EnvoyExtensionPolicy).Status, defaultEnvoyGatewayGatewayControllerName, gatewayAncestor, gatewayapiv1.Namespace(obj.GetNamespace())), string(gatewayapiv1alpha2.PolicyConditionAccepted))
221221
})...)
222222
default:
223223
componentsToSync = append(componentsToSync, fmt.Sprintf("%s (%s/%s)", machinery.GatewayGroupKind.Kind, g.gateway.GetNamespace(), g.gateway.GetName()))

0 commit comments

Comments
 (0)