Skip to content

Commit

Permalink
v1b1 everywhere for ref grant
Browse files Browse the repository at this point in the history
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
  • Loading branch information
arkodg committed Oct 19, 2023
1 parent caea44a commit 82a3b6a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
5 changes: 3 additions & 2 deletions internal/gatewayapi/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"
mcsapi "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
Expand All @@ -33,7 +34,7 @@ type Resources struct {
TLSRoutes []*gwapiv1a2.TLSRoute `json:"tlsRoutes,omitempty" yaml:"tlsRoutes,omitempty"`
TCPRoutes []*gwapiv1a2.TCPRoute `json:"tcpRoutes,omitempty" yaml:"tcpRoutes,omitempty"`
UDPRoutes []*gwapiv1a2.UDPRoute `json:"udpRoutes,omitempty" yaml:"udpRoutes,omitempty"`
ReferenceGrants []*gwapiv1a2.ReferenceGrant `json:"referenceGrants,omitempty" yaml:"referenceGrants,omitempty"`
ReferenceGrants []*gwapiv1b1.ReferenceGrant `json:"referenceGrants,omitempty" yaml:"referenceGrants,omitempty"`
Namespaces []*v1.Namespace `json:"namespaces,omitempty" yaml:"namespaces,omitempty"`
Services []*v1.Service `json:"services,omitempty" yaml:"services,omitempty"`
ServiceImports []*mcsapi.ServiceImport `json:"serviceImports,omitempty" yaml:"serviceImports,omitempty"`
Expand All @@ -56,7 +57,7 @@ func NewResources() *Resources {
Services: []*v1.Service{},
EndpointSlices: []*discoveryv1.EndpointSlice{},
Secrets: []*v1.Secret{},
ReferenceGrants: []*gwapiv1a2.ReferenceGrant{},
ReferenceGrants: []*gwapiv1b1.ReferenceGrant{},

Check warning on line 60 in internal/gatewayapi/resource.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/resource.go#L60

Added line #L60 was not covered by tests
Namespaces: []*v1.Namespace{},
RateLimitFilters: []*egv1a1.RateLimitFilter{},
AuthenticationFilters: []*egv1a1.AuthenticationFilter{},
Expand Down
14 changes: 7 additions & 7 deletions internal/gatewayapi/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/gateway-api/apis/v1alpha2"
"sigs.k8s.io/gateway-api/apis/v1beta1"
"sigs.k8s.io/yaml"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
Expand Down Expand Up @@ -537,7 +537,7 @@ func TestIsValidCrossNamespaceRef(t *testing.T) {
name string
from crossNamespaceFrom
to crossNamespaceTo
referenceGrant *v1alpha2.ReferenceGrant
referenceGrant *v1beta1.ReferenceGrant
want bool
}

Expand All @@ -559,20 +559,20 @@ func TestIsValidCrossNamespaceRef(t *testing.T) {
namespace: "default",
name: "tls-secret-1",
},
referenceGrant: &v1alpha2.ReferenceGrant{
referenceGrant: &v1beta1.ReferenceGrant{
ObjectMeta: metav1.ObjectMeta{
Name: "referencegrant-1",
Namespace: "default",
},
Spec: v1alpha2.ReferenceGrantSpec{
From: []v1alpha2.ReferenceGrantFrom{
Spec: v1beta1.ReferenceGrantSpec{
From: []v1beta1.ReferenceGrantFrom{
{
Group: "gateway.networking.k8s.io",
Kind: "Gateway",
Namespace: "envoy-gateway-system",
},
},
To: []v1alpha2.ReferenceGrantTo{
To: []v1beta1.ReferenceGrantTo{
{
Group: "",
Kind: "Secret",
Expand Down Expand Up @@ -642,7 +642,7 @@ func TestIsValidCrossNamespaceRef(t *testing.T) {
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
var referenceGrants []*v1alpha2.ReferenceGrant
var referenceGrants []*v1beta1.ReferenceGrant
if tc.referenceGrant != nil {
referenceGrants = append(referenceGrants, tc.referenceGrant)
}
Expand Down
3 changes: 2 additions & 1 deletion internal/gatewayapi/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"
)

func (t *Translator) validateBackendRef(backendRef *gwapiv1a2.BackendRef, parentRef *RouteParentContext, route RouteContext,
Expand Down Expand Up @@ -629,7 +630,7 @@ func (t *Translator) validateConflictedLayer4Listeners(gateways []*GatewayContex
}
}

func (t *Translator) validateCrossNamespaceRef(from crossNamespaceFrom, to crossNamespaceTo, referenceGrants []*gwapiv1a2.ReferenceGrant) bool {
func (t *Translator) validateCrossNamespaceRef(from crossNamespaceFrom, to crossNamespaceTo, referenceGrants []*gwapiv1b1.ReferenceGrant) bool {
for _, referenceGrant := range referenceGrants {
// The ReferenceGrant must be defined in the namespace of
// the "to" (the referent).
Expand Down
5 changes: 3 additions & 2 deletions internal/gatewayapi/zz_generated.deepcopy.go

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

0 comments on commit 82a3b6a

Please sign in to comment.