From e50dd4c9ef262c78214dd04d1499fb0d7aeeb1a2 Mon Sep 17 00:00:00 2001 From: qicz Date: Mon, 8 Apr 2024 19:42:18 +0800 Subject: [PATCH] refactor: gatewayclass controller Signed-off-by: qicz --- api/v1alpha1/envoygateway_types.go | 2 +- internal/cmd/egctl/translate.go | 6 +++--- internal/gatewayapi/translator.go | 2 +- internal/provider/kubernetes/controller.go | 2 +- site/content/en/latest/api/extension_types.md | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/v1alpha1/envoygateway_types.go b/api/v1alpha1/envoygateway_types.go index 47b9861e1702..1716d2286657 100644 --- a/api/v1alpha1/envoygateway_types.go +++ b/api/v1alpha1/envoygateway_types.go @@ -158,7 +158,7 @@ type Gateway struct { // https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.GatewayClass // // +optional - ControllerName string `json:"controllerName,omitempty"` + ControllerName gwapiv1.GatewayController `json:"controllerName,omitempty"` } // ExtensionAPISettings defines the settings specific to Gateway API Extensions. diff --git a/internal/cmd/egctl/translate.go b/internal/cmd/egctl/translate.go index 7935950bcbce..b588d931fbad 100644 --- a/internal/cmd/egctl/translate.go +++ b/internal/cmd/egctl/translate.go @@ -276,7 +276,7 @@ func translateGatewayAPIToIR(resources *gatewayapi.Resources) (*gatewayapi.Trans } t := &gatewayapi.Translator{ - GatewayControllerName: egv1a1.GatewayControllerName, + GatewayControllerName: resources.GatewayClass.Spec.ControllerName, GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name), GlobalRateLimitEnabled: true, EndpointRoutingDisabled: true, @@ -303,7 +303,7 @@ func translateGatewayAPIToGatewayAPI(resources *gatewayapi.Resources) (gatewayap // Translate from Gateway API to Xds IR gTranslator := &gatewayapi.Translator{ - GatewayControllerName: egv1a1.GatewayControllerName, + GatewayControllerName: resources.GatewayClass.Spec.ControllerName, GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name), GlobalRateLimitEnabled: true, EndpointRoutingDisabled: true, @@ -335,7 +335,7 @@ func translateGatewayAPIToXds(dnsDomain string, resourceType string, resources * // Translate from Gateway API to Xds IR gTranslator := &gatewayapi.Translator{ - GatewayControllerName: egv1a1.GatewayControllerName, + GatewayControllerName: resources.GatewayClass.Spec.ControllerName, GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name), GlobalRateLimitEnabled: true, EndpointRoutingDisabled: true, diff --git a/internal/gatewayapi/translator.go b/internal/gatewayapi/translator.go index 9dc93532479a..ca90be5b6932 100644 --- a/internal/gatewayapi/translator.go +++ b/internal/gatewayapi/translator.go @@ -66,7 +66,7 @@ type TranslatorManager interface { // for Gateway API resources. type Translator struct { // GatewayControllerName is the name of the Gateway API controller - GatewayControllerName string + GatewayControllerName gwapiv1.GatewayController // GatewayClassName is the name of the GatewayClass // to process Gateways for. diff --git a/internal/provider/kubernetes/controller.go b/internal/provider/kubernetes/controller.go index 571a45c5764e..a2b684045a5b 100644 --- a/internal/provider/kubernetes/controller.go +++ b/internal/provider/kubernetes/controller.go @@ -81,7 +81,7 @@ func newGatewayAPIController(mgr manager.Manager, cfg *config.Server, su status. r := &gatewayAPIReconciler{ client: mgr.GetClient(), log: cfg.Logger, - classController: gwapiv1.GatewayController(cfg.EnvoyGateway.Gateway.ControllerName), + classController: cfg.EnvoyGateway.Gateway.ControllerName, namespace: cfg.Namespace, statusUpdater: su, resources: resources, diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md index c3316f670265..072754de6631 100644 --- a/site/content/en/latest/api/extension_types.md +++ b/site/content/en/latest/api/extension_types.md @@ -1207,7 +1207,7 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | -| `controllerName` | _string_ | false | ControllerName defines the name of the Gateway API controller. If unspecified,
defaults to "gateway.envoyproxy.io/gatewayclass-controller". See the following
for additional details:
https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.GatewayClass | +| `controllerName` | _[GatewayController](#gatewaycontroller)_ | false | ControllerName defines the name of the Gateway API controller. If unspecified,
defaults to "gateway.envoyproxy.io/gatewayclass-controller". See the following
for additional details:
https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.GatewayClass | #### GlobalRateLimit