Skip to content

Commit

Permalink
fix: fix egctl does not support custom controller name.
Browse files Browse the repository at this point in the history
Signed-off-by: qicz <qiczzhu@gmail.com>
  • Loading branch information
qicz committed Apr 9, 2024
1 parent 180fbeb commit 67008f8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/cmd/egctl/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 67008f8

Please sign in to comment.