Skip to content

Commit

Permalink
fix: Fix Gateway API v1 package references
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy351 committed Mar 29, 2024
1 parent b0673e1 commit a75bf9c
Show file tree
Hide file tree
Showing 28 changed files with 921 additions and 899 deletions.
20 changes: 10 additions & 10 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 16 additions & 15 deletions internal/cmd/egctl/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/util/sets"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
"github.com/envoyproxy/gateway/api/v1alpha1/validation"
Expand Down Expand Up @@ -277,7 +278,7 @@ func translateGatewayAPIToIR(resources *gatewayapi.Resources) (*gatewayapi.Trans

t := &gatewayapi.Translator{
GatewayControllerName: egv1a1.GatewayControllerName,
GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name),
GatewayClassName: gwapiv1b1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
EndpointRoutingDisabled: true,
EnvoyPatchPolicyEnabled: true,
Expand All @@ -304,7 +305,7 @@ func translateGatewayAPIToGatewayAPI(resources *gatewayapi.Resources) (gatewayap
// Translate from Gateway API to Xds IR
gTranslator := &gatewayapi.Translator{
GatewayControllerName: egv1a1.GatewayControllerName,
GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name),
GatewayClassName: gwapiv1b1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
EndpointRoutingDisabled: true,
EnvoyPatchPolicyEnabled: true,
Expand Down Expand Up @@ -336,7 +337,7 @@ func translateGatewayAPIToXds(dnsDomain string, resourceType string, resources *
// Translate from Gateway API to Xds IR
gTranslator := &gatewayapi.Translator{
GatewayControllerName: egv1a1.GatewayControllerName,
GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name),
GatewayClassName: gwapiv1b1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
EndpointRoutingDisabled: true,
EnvoyPatchPolicyEnabled: true,
Expand Down Expand Up @@ -542,9 +543,9 @@ func addMissingServices(requiredServices map[string]*v1.Service, obj interface{}
var objNamespace string
protocol := v1.Protocol(gatewayapi.TCPProtocol)

refs := []gwapiv1.BackendRef{}
refs := []gwapiv1b1.BackendRef{}
switch route := obj.(type) {
case *gwapiv1.HTTPRoute:
case *gwapiv1b1.HTTPRoute:
objNamespace = route.Namespace
for _, rule := range route.Spec.Rules {
for _, httpBakcendRef := range rule.BackendRefs {
Expand Down Expand Up @@ -681,22 +682,22 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap
resources.EnvoyProxy = envoyProxy
case gatewayapi.KindGatewayClass:
typedSpec := spec.Interface()
gatewayClass := &gwapiv1.GatewayClass{
gatewayClass := &gwapiv1b1.GatewayClass{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: typedSpec.(gwapiv1.GatewayClassSpec),
Spec: typedSpec.(gwapiv1b1.GatewayClassSpec),
}
resources.GatewayClass = gatewayClass
case gatewayapi.KindGateway:
typedSpec := spec.Interface()
gateway := &gwapiv1.Gateway{
gateway := &gwapiv1b1.Gateway{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: typedSpec.(gwapiv1.GatewaySpec),
Spec: typedSpec.(gwapiv1b1.GatewaySpec),
}
resources.Gateways = append(resources.Gateways, gateway)
case gatewayapi.KindTCPRoute:
Expand Down Expand Up @@ -740,15 +741,15 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap
resources.TLSRoutes = append(resources.TLSRoutes, tlsRoute)
case gatewayapi.KindHTTPRoute:
typedSpec := spec.Interface()
httpRoute := &gwapiv1.HTTPRoute{
httpRoute := &gwapiv1b1.HTTPRoute{
TypeMeta: metav1.TypeMeta{
Kind: gatewayapi.KindHTTPRoute,
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: typedSpec.(gwapiv1.HTTPRouteSpec),
Spec: typedSpec.(gwapiv1b1.HTTPRouteSpec),
}
resources.HTTPRoutes = append(resources.HTTPRoutes, httpRoute)
case gatewayapi.KindGRPCRoute:
Expand Down Expand Up @@ -945,9 +946,9 @@ func addDefaultEnvoyProxy(resources *gatewayapi.Resources) error {
},
}
resources.EnvoyProxy = ep
ns := gwapiv1.Namespace(namespace)
resources.GatewayClass.Spec.ParametersRef = &gwapiv1.ParametersReference{
Group: gwapiv1.Group(egv1a1.GroupVersion.Group),
ns := gwapiv1b1.Namespace(namespace)
resources.GatewayClass.Spec.ParametersRef = &gwapiv1b1.ParametersReference{
Group: gwapiv1b1.Group(egv1a1.GroupVersion.Group),
Kind: gatewayapi.KindEnvoyProxy,
Name: defaultEnvoyProxyName,
Namespace: &ns,
Expand Down
2 changes: 1 addition & 1 deletion internal/envoygateway/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ package envoygateway
import (
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"
mcsapi "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"

Expand Down
Loading

0 comments on commit a75bf9c

Please sign in to comment.