From 67008f83dc7e10df2b5c94c578a9379c3b688be7 Mon Sep 17 00:00:00 2001 From: qicz Date: Tue, 9 Apr 2024 16:29:10 +0800 Subject: [PATCH] fix: fix egctl does not support custom controller name. Signed-off-by: qicz --- internal/cmd/egctl/translate.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/cmd/egctl/translate.go b/internal/cmd/egctl/translate.go index 7935950bcbc..a441378f52a 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: string(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: string(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: string(resources.GatewayClass.Spec.ControllerName), GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name), GlobalRateLimitEnabled: true, EndpointRoutingDisabled: true, @@ -688,6 +688,10 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap }, Spec: typedSpec.(gwapiv1.GatewayClassSpec), } + // fill controller name by default controller name when gatewayclass controller name empty. + if gatewayClass.Spec.ControllerName == "" { + gatewayClass.Spec.ControllerName = egv1a1.GatewayControllerName + } resources.GatewayClass = gatewayClass case gatewayapi.KindGateway: typedSpec := spec.Interface()