Skip to content

Commit

Permalink
address cr suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Kobi Levi <[email protected]>
  • Loading branch information
levikobi committed Jan 28, 2024
1 parent b52306c commit 00439a5
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@ gatewayClass:
reason: Accepted
status: "True"
type: Accepted
supportedFeatures:
- Gateway
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@ gatewayClass:
reason: Accepted
status: "True"
type: Accepted
supportedFeatures:
- Gateway
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@
"reason": "Accepted",
"message": "Valid GatewayClass"
}
],
"supportedFeatures": [
"Gateway",
"GatewayPort8080",
"GatewayStaticAddresses",
"HTTPRoute",
"HTTPRouteBackendProtocolH2C",
"HTTPRouteBackendProtocolWebSocket",
"HTTPRouteBackendTimeout",
"HTTPRouteDestinationPortMatching",
"HTTPRouteHostRewrite",
"HTTPRouteMethodMatching",
"HTTPRoutePathRedirect",
"HTTPRoutePathRewrite",
"HTTPRoutePortRedirect",
"HTTPRouteQueryParamMatching",
"HTTPRouteRequestMirror",
"HTTPRouteRequestMultipleMirrors",
"HTTPRouteRequestTimeout",
"HTTPRouteResponseHeaderModification",
"HTTPRouteSchemeRedirect",
"ReferenceGrant",
"TLSRoute"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ gatewayClass:
reason: InvalidParameters
status: "False"
type: Accepted
supportedFeatures:
- Gateway
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@ gatewayClass:
reason: Accepted
status: "True"
type: Accepted
supportedFeatures:
- Gateway
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ gatewayClass:
reason: Accepted
status: "True"
type: Accepted
supportedFeatures:
- Gateway
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/egctl/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,11 @@ func translateGatewayAPIToGatewayAPI(resources *gatewayapi.Resources) (gatewayap
epInvalid = true
msg := fmt.Sprintf("%s: %v", status.MsgGatewayClassInvalidParams, err)
status.SetGatewayClassAccepted(resources.GatewayClass, false, string(gwapiv1.GatewayClassReasonInvalidParameters), msg)
status.SetGatewayClassSupportedFeatures(resources.GatewayClass)
}
gRes.EnvoyProxy = resources.EnvoyProxy
}
if !epInvalid {
status.SetGatewayClassAccepted(resources.GatewayClass, true, string(gwapiv1.GatewayClassReasonAccepted), status.MsgValidGatewayClass)
status.SetGatewayClassSupportedFeatures(resources.GatewayClass)
}

gRes.GatewayClass = resources.GatewayClass
Expand Down
8 changes: 8 additions & 0 deletions internal/cmd/egctl/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/yaml"

"github.com/envoyproxy/gateway/internal/status"
"github.com/envoyproxy/gateway/internal/utils/field"
"github.com/envoyproxy/gateway/internal/utils/file"
)
Expand Down Expand Up @@ -344,6 +345,13 @@ func TestTranslate(t *testing.T) {
}
want := &TranslationResult{}
mustUnmarshal(t, requireTestDataOutFile(t, fn), want)

// Supported features are dynamic, instead of hard-coding them in the output files
// we define them here.
if want.GatewayClass != nil {
want.GatewayClass.Status.SupportedFeatures = status.GetSupportedFeatures()
}

opts := cmpopts.IgnoreFields(metav1.Condition{}, "LastTransitionTime")
require.Empty(t, cmp.Diff(want, got, opts))

Expand Down
21 changes: 7 additions & 14 deletions internal/status/gatewayclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,15 @@ package status
import (
"k8s.io/apimachinery/pkg/util/sets"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
)

// SetGatewayClassAccepted inserts or updates the Accepted condition
// for the provided GatewayClass.
func SetGatewayClassAccepted(gc *gwapiv1.GatewayClass, accepted bool, reason, msg string) *gwapiv1.GatewayClass {
gc.Status.Conditions = MergeConditions(gc.Status.Conditions, computeGatewayClassAcceptedCondition(gc, accepted, reason, msg))
return gc
}
"github.com/envoyproxy/gateway/test/conformance"
)

// GetSupportedFeatures returns a list of supported Gateway-API features,
// based on the running conformance tests suite.
func GetSupportedFeatures() []gwapiv1.SupportedFeature {

// TODO(levikobi): This must be in sync with the cSuite supported features.
supportedFeatures := suite.AllFeatures
supportedFeatures.Delete(suite.MeshCoreFeatures.UnsortedList()...)
supportedFeatures := conformance.EnvoyGatewaySuite.SupportedFeatures
supportedFeatures.Delete(conformance.EnvoyGatewaySuite.ExemptFeatures.UnsortedList()...)

ret := sets.New[gwapiv1.SupportedFeature]()
for _, feature := range supportedFeatures.UnsortedList() {
Expand All @@ -41,9 +33,10 @@ func GetSupportedFeatures() []gwapiv1.SupportedFeature {
return sets.List(ret)
}

// SetGatewayClassSupportedFeatures insert or updates the SupportedFeatures field
// SetGatewayClassAccepted inserts or updates the Accepted condition
// for the provided GatewayClass.
func SetGatewayClassSupportedFeatures(gc *gwapiv1.GatewayClass) *gwapiv1.GatewayClass {
func SetGatewayClassAccepted(gc *gwapiv1.GatewayClass, accepted bool, reason, msg string) *gwapiv1.GatewayClass {
gc.Status.Conditions = MergeConditions(gc.Status.Conditions, computeGatewayClassAcceptedCondition(gc, accepted, reason, msg))
gc.Status.SupportedFeatures = GetSupportedFeatures()
return gc
}
17 changes: 17 additions & 0 deletions test/conformance/conformance_features.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package conformance

import (
"sigs.k8s.io/gateway-api/conformance/tests"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
)

var EnvoyGatewaySuite = suite.Options{
SupportedFeatures: suite.AllFeatures,
ExemptFeatures: suite.MeshCoreFeatures,
SkipTests: []string{tests.GatewayStaticAddresses.ShortName},
}
8 changes: 3 additions & 5 deletions test/conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ func TestGatewayAPIConformance(t *testing.T) {
Debug: *flags.ShowDebug,
Clientset: clientset,
CleanupBaseResources: *flags.CleanupBaseResources,
SupportedFeatures: suite.AllFeatures,
SkipTests: []string{
tests.GatewayStaticAddresses.ShortName,
},
ExemptFeatures: suite.MeshCoreFeatures,
SupportedFeatures: EnvoyGatewaySuite.SupportedFeatures,
SkipTests: EnvoyGatewaySuite.SkipTests,
ExemptFeatures: EnvoyGatewaySuite.ExemptFeatures,
})
cSuite.Setup(t)
cSuite.Run(t, tests.ConformanceTests)
Expand Down
8 changes: 3 additions & 5 deletions test/conformance/experimental_conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ func experimentalConformance(t *testing.T) {
GatewayClassName: *flags.GatewayClassName,
Debug: *flags.ShowDebug,
CleanupBaseResources: *flags.CleanupBaseResources,
SupportedFeatures: suite.AllFeatures,
SkipTests: []string{
tests.GatewayStaticAddresses.ShortName,
},
ExemptFeatures: suite.MeshCoreFeatures,
SupportedFeatures: EnvoyGatewaySuite.SupportedFeatures,
SkipTests: EnvoyGatewaySuite.SkipTests,
ExemptFeatures: EnvoyGatewaySuite.ExemptFeatures,
},
Implementation: *implementation,
ConformanceProfiles: conformanceProfiles,
Expand Down

0 comments on commit 00439a5

Please sign in to comment.