Skip to content

Commit 7a51a8e

Browse files
committed
feat: add supported features to gateway class
Signed-off-by: Kobi Levi <[email protected]>
1 parent 7c9dfc5 commit 7a51a8e

12 files changed

+228
-16
lines changed

internal/cmd/egctl/testdata/translate/out/default-resources.all.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,34 @@ gatewayClass:
158158
reason: Accepted
159159
status: "True"
160160
type: Accepted
161+
supportedFeatures:
162+
- GRPCRoute
163+
- Gateway
164+
- GatewayHTTPListenerIsolation
165+
- GatewayPort8080
166+
- GatewayStaticAddresses
167+
- HTTPRoute
168+
- HTTPRouteBackendProtocolH2C
169+
- HTTPRouteBackendProtocolWebSocket
170+
- HTTPRouteBackendRequestHeaderModification
171+
- HTTPRouteBackendTimeout
172+
- HTTPRouteDestinationPortMatching
173+
- HTTPRouteHostRewrite
174+
- HTTPRouteMethodMatching
175+
- HTTPRouteParentRefPort
176+
- HTTPRoutePathRedirect
177+
- HTTPRoutePathRewrite
178+
- HTTPRoutePortRedirect
179+
- HTTPRouteQueryParamMatching
180+
- HTTPRouteRequestMirror
181+
- HTTPRouteRequestMultipleMirrors
182+
- HTTPRouteRequestTimeout
183+
- HTTPRouteResponseHeaderModification
184+
- HTTPRouteSchemeRedirect
185+
- MeshClusterIPMatching
186+
- MeshConsumerRoute
187+
- ReferenceGrant
188+
- TLSRoute
161189
gateways:
162190
- metadata:
163191
creationTimestamp: null

internal/cmd/egctl/testdata/translate/out/echo-gateway-api.cluster.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ gatewayClass:
1212
reason: Accepted
1313
status: "True"
1414
type: Accepted
15+
supportedFeatures:
16+
- GRPCRoute
17+
- Gateway
18+
- GatewayHTTPListenerIsolation
19+
- GatewayPort8080
20+
- GatewayStaticAddresses
21+
- HTTPRoute
22+
- HTTPRouteBackendProtocolH2C
23+
- HTTPRouteBackendProtocolWebSocket
24+
- HTTPRouteBackendRequestHeaderModification
25+
- HTTPRouteBackendTimeout
26+
- HTTPRouteDestinationPortMatching
27+
- HTTPRouteHostRewrite
28+
- HTTPRouteMethodMatching
29+
- HTTPRouteParentRefPort
30+
- HTTPRoutePathRedirect
31+
- HTTPRoutePathRewrite
32+
- HTTPRoutePortRedirect
33+
- HTTPRouteQueryParamMatching
34+
- HTTPRouteRequestMirror
35+
- HTTPRouteRequestMultipleMirrors
36+
- HTTPRouteRequestTimeout
37+
- HTTPRouteResponseHeaderModification
38+
- HTTPRouteSchemeRedirect
39+
- MeshClusterIPMatching
40+
- MeshConsumerRoute
41+
- ReferenceGrant
42+
- TLSRoute
1543
gateways:
1644
- metadata:
1745
creationTimestamp: null

internal/cmd/egctl/testdata/translate/out/echo-gateway-api.route.json

+29
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,35 @@
1717
"reason": "Accepted",
1818
"message": "Valid GatewayClass"
1919
}
20+
],
21+
"supportedFeatures": [
22+
"GRPCRoute",
23+
"Gateway",
24+
"GatewayHTTPListenerIsolation",
25+
"GatewayPort8080",
26+
"GatewayStaticAddresses",
27+
"HTTPRoute",
28+
"HTTPRouteBackendProtocolH2C",
29+
"HTTPRouteBackendProtocolWebSocket",
30+
"HTTPRouteBackendRequestHeaderModification",
31+
"HTTPRouteBackendTimeout",
32+
"HTTPRouteDestinationPortMatching",
33+
"HTTPRouteHostRewrite",
34+
"HTTPRouteMethodMatching",
35+
"HTTPRouteParentRefPort",
36+
"HTTPRoutePathRedirect",
37+
"HTTPRoutePathRewrite",
38+
"HTTPRoutePortRedirect",
39+
"HTTPRouteQueryParamMatching",
40+
"HTTPRouteRequestMirror",
41+
"HTTPRouteRequestMultipleMirrors",
42+
"HTTPRouteRequestTimeout",
43+
"HTTPRouteResponseHeaderModification",
44+
"HTTPRouteSchemeRedirect",
45+
"MeshClusterIPMatching",
46+
"MeshConsumerRoute",
47+
"ReferenceGrant",
48+
"TLSRoute"
2049
]
2150
}
2251
},

internal/cmd/egctl/testdata/translate/out/invalid-envoyproxy.all.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,34 @@ gatewayClass:
3838
reason: InvalidParameters
3939
status: "False"
4040
type: Accepted
41+
supportedFeatures:
42+
- GRPCRoute
43+
- Gateway
44+
- GatewayHTTPListenerIsolation
45+
- GatewayPort8080
46+
- GatewayStaticAddresses
47+
- HTTPRoute
48+
- HTTPRouteBackendProtocolH2C
49+
- HTTPRouteBackendProtocolWebSocket
50+
- HTTPRouteBackendRequestHeaderModification
51+
- HTTPRouteBackendTimeout
52+
- HTTPRouteDestinationPortMatching
53+
- HTTPRouteHostRewrite
54+
- HTTPRouteMethodMatching
55+
- HTTPRouteParentRefPort
56+
- HTTPRoutePathRedirect
57+
- HTTPRoutePathRewrite
58+
- HTTPRoutePortRedirect
59+
- HTTPRouteQueryParamMatching
60+
- HTTPRouteRequestMirror
61+
- HTTPRouteRequestMultipleMirrors
62+
- HTTPRouteRequestTimeout
63+
- HTTPRouteResponseHeaderModification
64+
- HTTPRouteSchemeRedirect
65+
- MeshClusterIPMatching
66+
- MeshConsumerRoute
67+
- ReferenceGrant
68+
- TLSRoute
4169
gateways:
4270
- metadata:
4371
creationTimestamp: null

internal/cmd/egctl/testdata/translate/out/rejected-http-route.route.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ gatewayClass:
1212
reason: Accepted
1313
status: "True"
1414
type: Accepted
15+
supportedFeatures:
16+
- GRPCRoute
17+
- Gateway
18+
- GatewayHTTPListenerIsolation
19+
- GatewayPort8080
20+
- GatewayStaticAddresses
21+
- HTTPRoute
22+
- HTTPRouteBackendProtocolH2C
23+
- HTTPRouteBackendProtocolWebSocket
24+
- HTTPRouteBackendRequestHeaderModification
25+
- HTTPRouteBackendTimeout
26+
- HTTPRouteDestinationPortMatching
27+
- HTTPRouteHostRewrite
28+
- HTTPRouteMethodMatching
29+
- HTTPRouteParentRefPort
30+
- HTTPRoutePathRedirect
31+
- HTTPRoutePathRewrite
32+
- HTTPRoutePortRedirect
33+
- HTTPRouteQueryParamMatching
34+
- HTTPRouteRequestMirror
35+
- HTTPRouteRequestMultipleMirrors
36+
- HTTPRouteRequestTimeout
37+
- HTTPRouteResponseHeaderModification
38+
- HTTPRouteSchemeRedirect
39+
- MeshClusterIPMatching
40+
- MeshConsumerRoute
41+
- ReferenceGrant
42+
- TLSRoute
1543
gateways:
1644
- metadata:
1745
creationTimestamp: null

internal/cmd/egctl/testdata/translate/out/valid-envoyproxy.all.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,34 @@ gatewayClass:
3131
reason: Accepted
3232
status: "True"
3333
type: Accepted
34+
supportedFeatures:
35+
- GRPCRoute
36+
- Gateway
37+
- GatewayHTTPListenerIsolation
38+
- GatewayPort8080
39+
- GatewayStaticAddresses
40+
- HTTPRoute
41+
- HTTPRouteBackendProtocolH2C
42+
- HTTPRouteBackendProtocolWebSocket
43+
- HTTPRouteBackendRequestHeaderModification
44+
- HTTPRouteBackendTimeout
45+
- HTTPRouteDestinationPortMatching
46+
- HTTPRouteHostRewrite
47+
- HTTPRouteMethodMatching
48+
- HTTPRouteParentRefPort
49+
- HTTPRoutePathRedirect
50+
- HTTPRoutePathRewrite
51+
- HTTPRoutePortRedirect
52+
- HTTPRouteQueryParamMatching
53+
- HTTPRouteRequestMirror
54+
- HTTPRouteRequestMultipleMirrors
55+
- HTTPRouteRequestTimeout
56+
- HTTPRouteResponseHeaderModification
57+
- HTTPRouteSchemeRedirect
58+
- MeshClusterIPMatching
59+
- MeshConsumerRoute
60+
- ReferenceGrant
61+
- TLSRoute
3462
gateways:
3563
- metadata:
3664
creationTimestamp: null

internal/cmd/egctl/translate_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
"sigs.k8s.io/yaml"
2424

25+
"github.com/envoyproxy/gateway/internal/gatewayapi/status"
2526
"github.com/envoyproxy/gateway/internal/utils/field"
2627
"github.com/envoyproxy/gateway/internal/utils/file"
2728
)
@@ -349,6 +350,13 @@ func TestTranslate(t *testing.T) {
349350
}
350351
want := &TranslationResult{}
351352
mustUnmarshal(t, requireTestDataOutFile(t, fn), want)
353+
354+
// Supported features are dynamic, instead of hard-coding them in the output files
355+
// we define them here.
356+
if want.GatewayClass != nil {
357+
want.GatewayClass.Status.SupportedFeatures = status.GatewaySupportedFeatures
358+
}
359+
352360
opts := cmpopts.IgnoreFields(metav1.Condition{}, "LastTransitionTime")
353361
require.Empty(t, cmp.Diff(want, got, opts))
354362
})

internal/gatewayapi/status/gatewayclass.go

+18
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
package status
1515

1616
import (
17+
"github.com/envoyproxy/gateway/test/conformance"
18+
"k8s.io/apimachinery/pkg/util/sets"
1719
"time"
1820

1921
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -32,6 +34,7 @@ const (
3234
// for the provided GatewayClass.
3335
func SetGatewayClassAccepted(gc *gwapiv1.GatewayClass, accepted bool, reason, msg string) *gwapiv1.GatewayClass {
3436
gc.Status.Conditions = MergeConditions(gc.Status.Conditions, computeGatewayClassAcceptedCondition(gc, accepted, reason, msg))
37+
gc.Status.SupportedFeatures = GatewaySupportedFeatures
3538
return gc
3639
}
3740

@@ -61,3 +64,18 @@ func computeGatewayClassAcceptedCondition(gatewayClass *gwapiv1.GatewayClass,
6164
}
6265
}
6366
}
67+
68+
// GatewaySupportedFeatures is a list of supported Gateway-API features,
69+
// based on the running conformance tests suite.
70+
var GatewaySupportedFeatures = getSupportedFeatures()
71+
72+
func getSupportedFeatures() []gwapiv1.SupportedFeature {
73+
supportedFeatures := conformance.EnvoyGatewaySuite.SupportedFeatures
74+
supportedFeatures.Delete(conformance.EnvoyGatewaySuite.ExemptFeatures.UnsortedList()...)
75+
76+
ret := sets.New[gwapiv1.SupportedFeature]()
77+
for _, feature := range supportedFeatures.UnsortedList() {
78+
ret.Insert(gwapiv1.SupportedFeature(feature))
79+
}
80+
return sets.List(ret)
81+
}

internal/provider/kubernetes/controller_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/envoyproxy/gateway/internal/envoygateway"
2121
"github.com/envoyproxy/gateway/internal/envoygateway/config"
2222
"github.com/envoyproxy/gateway/internal/gatewayapi"
23+
"github.com/envoyproxy/gateway/internal/gatewayapi/status"
2324
"github.com/envoyproxy/gateway/internal/logging"
2425
)
2526

@@ -189,6 +190,7 @@ func TestHasManagedClass(t *testing.T) {
189190
Status: metav1.ConditionTrue,
190191
},
191192
},
193+
SupportedFeatures: status.GatewaySupportedFeatures,
192194
},
193195
},
194196
},
@@ -223,6 +225,7 @@ func TestHasManagedClass(t *testing.T) {
223225
Status: metav1.ConditionTrue,
224226
},
225227
},
228+
SupportedFeatures: status.GatewaySupportedFeatures,
226229
},
227230
},
228231
},
@@ -275,6 +278,7 @@ func TestHasManagedClass(t *testing.T) {
275278
Status: metav1.ConditionTrue,
276279
},
277280
},
281+
SupportedFeatures: status.GatewaySupportedFeatures,
278282
},
279283
},
280284
{
@@ -297,6 +301,7 @@ func TestHasManagedClass(t *testing.T) {
297301
Status: metav1.ConditionFalse,
298302
},
299303
},
304+
SupportedFeatures: status.GatewaySupportedFeatures,
300305
},
301306
},
302307
},
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright Envoy Gateway Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
// The full text of the Apache license is available in the LICENSE file at
4+
// the root of the repo.
5+
6+
package conformance
7+
8+
import (
9+
"sigs.k8s.io/gateway-api/conformance/tests"
10+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
11+
"sigs.k8s.io/gateway-api/pkg/features"
12+
)
13+
14+
var EnvoyGatewaySuite = suite.ConformanceOptions{
15+
SupportedFeatures: features.AllFeatures,
16+
ExemptFeatures: features.MeshCoreFeatures,
17+
SkipTests: []string{
18+
tests.GatewayStaticAddresses.ShortName,
19+
tests.GatewayHTTPListenerIsolation.ShortName, // https://github.com/kubernetes-sigs/gateway-api/issues/3049
20+
tests.HTTPRouteBackendRequestHeaderModifier.ShortName, // https://github.com/envoyproxy/gateway/issues/3338
21+
},
22+
}

test/conformance/conformance_test.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,15 @@ import (
1515
"sigs.k8s.io/gateway-api/conformance"
1616
"sigs.k8s.io/gateway-api/conformance/tests"
1717
"sigs.k8s.io/gateway-api/conformance/utils/suite"
18-
"sigs.k8s.io/gateway-api/pkg/features"
1918
)
2019

2120
func TestGatewayAPIConformance(t *testing.T) {
2221
flag.Parse()
2322

2423
opts := conformance.DefaultOptions(t)
25-
opts.SkipTests = []string{
26-
tests.GatewayStaticAddresses.ShortName,
27-
tests.GatewayHTTPListenerIsolation.ShortName, // https://github.com/kubernetes-sigs/gateway-api/issues/3049
28-
tests.HTTPRouteBackendRequestHeaderModifier.ShortName, // https://github.com/envoyproxy/gateway/issues/3338
29-
}
30-
opts.SupportedFeatures = features.AllFeatures
31-
opts.ExemptFeatures = features.MeshCoreFeatures
24+
opts.SkipTests = EnvoyGatewaySuite.SkipTests
25+
opts.SupportedFeatures = EnvoyGatewaySuite.SupportedFeatures
26+
opts.ExemptFeatures = EnvoyGatewaySuite.ExemptFeatures
3227

3328
cSuite, err := suite.NewConformanceTestSuite(opts)
3429
if err != nil {

test/conformance/experimental_conformance_test.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,16 @@ import (
2020
"sigs.k8s.io/gateway-api/conformance/tests"
2121
"sigs.k8s.io/gateway-api/conformance/utils/flags"
2222
"sigs.k8s.io/gateway-api/conformance/utils/suite"
23-
"sigs.k8s.io/gateway-api/pkg/features"
2423
"sigs.k8s.io/yaml"
2524
)
2625

2726
func TestExperimentalConformance(t *testing.T) {
2827
flag.Parse()
2928

3029
opts := conformance.DefaultOptions(t)
31-
opts.SkipTests = []string{
32-
tests.GatewayStaticAddresses.ShortName,
33-
tests.GatewayHTTPListenerIsolation.ShortName, // https://github.com/kubernetes-sigs/gateway-api/issues/3049
34-
tests.HTTPRouteBackendRequestHeaderModifier.ShortName, // https://github.com/envoyproxy/gateway/issues/3338
35-
}
36-
opts.SupportedFeatures = features.AllFeatures
37-
opts.ExemptFeatures = features.MeshCoreFeatures
30+
opts.SkipTests = EnvoyGatewaySuite.SkipTests
31+
opts.SupportedFeatures = EnvoyGatewaySuite.SupportedFeatures
32+
opts.ExemptFeatures = EnvoyGatewaySuite.ExemptFeatures
3833
opts.ConformanceProfiles = sets.New(
3934
suite.GatewayHTTPConformanceProfileName,
4035
suite.GatewayTLSConformanceProfileName,

0 commit comments

Comments
 (0)