Skip to content

Commit 5d7a94c

Browse files
committed
address cr suggestions
Signed-off-by: Kobi Levi <[email protected]>
1 parent 76fefcb commit 5d7a94c

13 files changed

+179
-32
lines changed

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

+22
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,28 @@ gatewayClass:
158158
reason: Accepted
159159
status: "True"
160160
type: Accepted
161+
supportedFeatures:
162+
- Gateway
163+
- GatewayPort8080
164+
- GatewayStaticAddresses
165+
- HTTPRoute
166+
- HTTPRouteBackendProtocolH2C
167+
- HTTPRouteBackendProtocolWebSocket
168+
- HTTPRouteBackendTimeout
169+
- HTTPRouteDestinationPortMatching
170+
- HTTPRouteHostRewrite
171+
- HTTPRouteMethodMatching
172+
- HTTPRoutePathRedirect
173+
- HTTPRoutePathRewrite
174+
- HTTPRoutePortRedirect
175+
- HTTPRouteQueryParamMatching
176+
- HTTPRouteRequestMirror
177+
- HTTPRouteRequestMultipleMirrors
178+
- HTTPRouteRequestTimeout
179+
- HTTPRouteResponseHeaderModification
180+
- HTTPRouteSchemeRedirect
181+
- ReferenceGrant
182+
- TLSRoute
161183
gateways:
162184
- metadata:
163185
creationTimestamp: null

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

+22
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ gatewayClass:
1212
reason: Accepted
1313
status: "True"
1414
type: Accepted
15+
supportedFeatures:
16+
- Gateway
17+
- GatewayPort8080
18+
- GatewayStaticAddresses
19+
- HTTPRoute
20+
- HTTPRouteBackendProtocolH2C
21+
- HTTPRouteBackendProtocolWebSocket
22+
- HTTPRouteBackendTimeout
23+
- HTTPRouteDestinationPortMatching
24+
- HTTPRouteHostRewrite
25+
- HTTPRouteMethodMatching
26+
- HTTPRoutePathRedirect
27+
- HTTPRoutePathRewrite
28+
- HTTPRoutePortRedirect
29+
- HTTPRouteQueryParamMatching
30+
- HTTPRouteRequestMirror
31+
- HTTPRouteRequestMultipleMirrors
32+
- HTTPRouteRequestTimeout
33+
- HTTPRouteResponseHeaderModification
34+
- HTTPRouteSchemeRedirect
35+
- ReferenceGrant
36+
- TLSRoute
1537
gateways:
1638
- metadata:
1739
creationTimestamp: null

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

+23
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,29 @@
1717
"reason": "Accepted",
1818
"message": "Valid GatewayClass"
1919
}
20+
],
21+
"supportedFeatures": [
22+
"Gateway",
23+
"GatewayPort8080",
24+
"GatewayStaticAddresses",
25+
"HTTPRoute",
26+
"HTTPRouteBackendProtocolH2C",
27+
"HTTPRouteBackendProtocolWebSocket",
28+
"HTTPRouteBackendTimeout",
29+
"HTTPRouteDestinationPortMatching",
30+
"HTTPRouteHostRewrite",
31+
"HTTPRouteMethodMatching",
32+
"HTTPRoutePathRedirect",
33+
"HTTPRoutePathRewrite",
34+
"HTTPRoutePortRedirect",
35+
"HTTPRouteQueryParamMatching",
36+
"HTTPRouteRequestMirror",
37+
"HTTPRouteRequestMultipleMirrors",
38+
"HTTPRouteRequestTimeout",
39+
"HTTPRouteResponseHeaderModification",
40+
"HTTPRouteSchemeRedirect",
41+
"ReferenceGrant",
42+
"TLSRoute"
2043
]
2144
}
2245
},

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

+22
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ gatewayClass:
3838
reason: InvalidParameters
3939
status: "False"
4040
type: Accepted
41+
supportedFeatures:
42+
- Gateway
43+
- GatewayPort8080
44+
- GatewayStaticAddresses
45+
- HTTPRoute
46+
- HTTPRouteBackendProtocolH2C
47+
- HTTPRouteBackendProtocolWebSocket
48+
- HTTPRouteBackendTimeout
49+
- HTTPRouteDestinationPortMatching
50+
- HTTPRouteHostRewrite
51+
- HTTPRouteMethodMatching
52+
- HTTPRoutePathRedirect
53+
- HTTPRoutePathRewrite
54+
- HTTPRoutePortRedirect
55+
- HTTPRouteQueryParamMatching
56+
- HTTPRouteRequestMirror
57+
- HTTPRouteRequestMultipleMirrors
58+
- HTTPRouteRequestTimeout
59+
- HTTPRouteResponseHeaderModification
60+
- HTTPRouteSchemeRedirect
61+
- ReferenceGrant
62+
- TLSRoute
4163
gateways:
4264
- metadata:
4365
creationTimestamp: null

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

+22
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ gatewayClass:
1212
reason: Accepted
1313
status: "True"
1414
type: Accepted
15+
supportedFeatures:
16+
- Gateway
17+
- GatewayPort8080
18+
- GatewayStaticAddresses
19+
- HTTPRoute
20+
- HTTPRouteBackendProtocolH2C
21+
- HTTPRouteBackendProtocolWebSocket
22+
- HTTPRouteBackendTimeout
23+
- HTTPRouteDestinationPortMatching
24+
- HTTPRouteHostRewrite
25+
- HTTPRouteMethodMatching
26+
- HTTPRoutePathRedirect
27+
- HTTPRoutePathRewrite
28+
- HTTPRoutePortRedirect
29+
- HTTPRouteQueryParamMatching
30+
- HTTPRouteRequestMirror
31+
- HTTPRouteRequestMultipleMirrors
32+
- HTTPRouteRequestTimeout
33+
- HTTPRouteResponseHeaderModification
34+
- HTTPRouteSchemeRedirect
35+
- ReferenceGrant
36+
- TLSRoute
1537
gateways:
1638
- metadata:
1739
creationTimestamp: null

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

+22
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ gatewayClass:
3131
reason: Accepted
3232
status: "True"
3333
type: Accepted
34+
supportedFeatures:
35+
- Gateway
36+
- GatewayPort8080
37+
- GatewayStaticAddresses
38+
- HTTPRoute
39+
- HTTPRouteBackendProtocolH2C
40+
- HTTPRouteBackendProtocolWebSocket
41+
- HTTPRouteBackendTimeout
42+
- HTTPRouteDestinationPortMatching
43+
- HTTPRouteHostRewrite
44+
- HTTPRouteMethodMatching
45+
- HTTPRoutePathRedirect
46+
- HTTPRoutePathRewrite
47+
- HTTPRoutePortRedirect
48+
- HTTPRouteQueryParamMatching
49+
- HTTPRouteRequestMirror
50+
- HTTPRouteRequestMultipleMirrors
51+
- HTTPRouteRequestTimeout
52+
- HTTPRouteResponseHeaderModification
53+
- HTTPRouteSchemeRedirect
54+
- ReferenceGrant
55+
- TLSRoute
3456
gateways:
3557
- metadata:
3658
creationTimestamp: null

internal/cmd/egctl/translate.go

-2
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,11 @@ func translateGatewayAPIToGatewayAPI(resources *gatewayapi.Resources) (gatewayap
319319
epInvalid = true
320320
msg := fmt.Sprintf("%s: %v", status.MsgGatewayClassInvalidParams, err)
321321
status.SetGatewayClassAccepted(resources.GatewayClass, false, string(gwapiv1.GatewayClassReasonInvalidParameters), msg)
322-
status.SetGatewayClassSupportedFeatures(resources.GatewayClass)
323322
}
324323
gRes.EnvoyProxy = resources.EnvoyProxy
325324
}
326325
if !epInvalid {
327326
status.SetGatewayClassAccepted(resources.GatewayClass, true, string(gwapiv1.GatewayClassReasonAccepted), status.MsgValidGatewayClass)
328-
status.SetGatewayClassSupportedFeatures(resources.GatewayClass)
329327
}
330328

331329
gRes.GatewayClass = resources.GatewayClass

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/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/provider/kubernetes/controller_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func TestHasManagedClass(t *testing.T) {
190190
Status: metav1.ConditionTrue,
191191
},
192192
},
193-
SupportedFeatures: status.GetSupportedFeatures(),
193+
SupportedFeatures: status.GatewaySupportedFeatures,
194194
},
195195
},
196196
},
@@ -225,7 +225,7 @@ func TestHasManagedClass(t *testing.T) {
225225
Status: metav1.ConditionTrue,
226226
},
227227
},
228-
SupportedFeatures: status.GetSupportedFeatures(),
228+
SupportedFeatures: status.GatewaySupportedFeatures,
229229
},
230230
},
231231
},
@@ -278,7 +278,7 @@ func TestHasManagedClass(t *testing.T) {
278278
Status: metav1.ConditionTrue,
279279
},
280280
},
281-
SupportedFeatures: status.GetSupportedFeatures(),
281+
SupportedFeatures: status.GatewaySupportedFeatures,
282282
},
283283
},
284284
{
@@ -301,7 +301,7 @@ func TestHasManagedClass(t *testing.T) {
301301
Status: metav1.ConditionFalse,
302302
},
303303
},
304-
SupportedFeatures: status.GetSupportedFeatures(),
304+
SupportedFeatures: status.GatewaySupportedFeatures,
305305
},
306306
},
307307
},

internal/status/gatewayclass.go

+11-16
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,17 @@ package status
1616
import (
1717
"k8s.io/apimachinery/pkg/util/sets"
1818
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
19-
"sigs.k8s.io/gateway-api/conformance/utils/suite"
20-
)
2119

22-
// SetGatewayClassAccepted inserts or updates the Accepted condition
23-
// for the provided GatewayClass.
24-
func SetGatewayClassAccepted(gc *gwapiv1.GatewayClass, accepted bool, reason, msg string) *gwapiv1.GatewayClass {
25-
gc.Status.Conditions = MergeConditions(gc.Status.Conditions, computeGatewayClassAcceptedCondition(gc, accepted, reason, msg))
26-
return gc
27-
}
20+
"github.com/envoyproxy/gateway/test/conformance"
21+
)
2822

29-
// GetSupportedFeatures returns a list of supported Gateway-API features,
23+
// GatewaySupportedFeatures is a list of supported Gateway-API features,
3024
// based on the running conformance tests suite.
31-
func GetSupportedFeatures() []gwapiv1.SupportedFeature {
25+
var GatewaySupportedFeatures = getSupportedFeatures()
3226

33-
// TODO(levikobi): This must be in sync with the cSuite supported features.
34-
supportedFeatures := suite.AllFeatures
35-
supportedFeatures.Delete(suite.MeshCoreFeatures.UnsortedList()...)
27+
func getSupportedFeatures() []gwapiv1.SupportedFeature {
28+
supportedFeatures := conformance.EnvoyGatewaySuite.SupportedFeatures
29+
supportedFeatures.Delete(conformance.EnvoyGatewaySuite.ExemptFeatures.UnsortedList()...)
3630

3731
ret := sets.New[gwapiv1.SupportedFeature]()
3832
for _, feature := range supportedFeatures.UnsortedList() {
@@ -41,9 +35,10 @@ func GetSupportedFeatures() []gwapiv1.SupportedFeature {
4135
return sets.List(ret)
4236
}
4337

44-
// SetGatewayClassSupportedFeatures insert or updates the SupportedFeatures field
38+
// SetGatewayClassAccepted inserts or updates the Accepted condition
4539
// for the provided GatewayClass.
46-
func SetGatewayClassSupportedFeatures(gc *gwapiv1.GatewayClass) *gwapiv1.GatewayClass {
47-
gc.Status.SupportedFeatures = GetSupportedFeatures()
40+
func SetGatewayClassAccepted(gc *gwapiv1.GatewayClass, accepted bool, reason, msg string) *gwapiv1.GatewayClass {
41+
gc.Status.Conditions = MergeConditions(gc.Status.Conditions, computeGatewayClassAcceptedCondition(gc, accepted, reason, msg))
42+
gc.Status.SupportedFeatures = GatewaySupportedFeatures
4843
return gc
4944
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
)
12+
13+
var EnvoyGatewaySuite = suite.Options{
14+
SupportedFeatures: suite.AllFeatures,
15+
ExemptFeatures: suite.MeshCoreFeatures,
16+
SkipTests: []string{tests.GatewayStaticAddresses.ShortName},
17+
}

test/conformance/conformance_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ func TestGatewayAPIConformance(t *testing.T) {
4646
Debug: *flags.ShowDebug,
4747
Clientset: clientset,
4848
CleanupBaseResources: *flags.CleanupBaseResources,
49-
SupportedFeatures: suite.AllFeatures,
50-
SkipTests: []string{
51-
tests.GatewayStaticAddresses.ShortName,
52-
},
53-
ExemptFeatures: suite.MeshCoreFeatures,
49+
SupportedFeatures: EnvoyGatewaySuite.SupportedFeatures,
50+
SkipTests: EnvoyGatewaySuite.SkipTests,
51+
ExemptFeatures: EnvoyGatewaySuite.ExemptFeatures,
5452
})
5553
cSuite.Setup(t)
5654
cSuite.Run(t, tests.ConformanceTests)

test/conformance/experimental_conformance_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@ func experimentalConformance(t *testing.T) {
9595
GatewayClassName: *flags.GatewayClassName,
9696
Debug: *flags.ShowDebug,
9797
CleanupBaseResources: *flags.CleanupBaseResources,
98-
SupportedFeatures: suite.AllFeatures,
99-
SkipTests: []string{
100-
tests.GatewayStaticAddresses.ShortName,
101-
},
102-
ExemptFeatures: suite.MeshCoreFeatures,
98+
SupportedFeatures: EnvoyGatewaySuite.SupportedFeatures,
99+
SkipTests: EnvoyGatewaySuite.SkipTests,
100+
ExemptFeatures: EnvoyGatewaySuite.ExemptFeatures,
103101
},
104102
Implementation: *implementation,
105103
ConformanceProfiles: conformanceProfiles,

0 commit comments

Comments
 (0)