@@ -15,6 +15,21 @@ const SupportedTCPRoute gatewayfeatures.FeatureName = "TCPRoute"
1515// supports session persistence configuration in BackendLBPolicy.
1616const SupportedBackendLBSessionPersistence gatewayfeatures.FeatureName = "BackendLBSessionPersistence"
1717
18+ // FeatureOptions controls which supported features are advertised for a
19+ // particular control-plane runtime configuration.
20+ type FeatureOptions struct {
21+ EnableExperimentalGateway bool
22+ }
23+
24+ var experimentalGatewayFeatures = []gatewayfeatures.FeatureName {
25+ gatewayfeatures .SupportListenerSet ,
26+ SupportedTCPRoute ,
27+ gatewayfeatures .SupportUDPRoute ,
28+ gatewayfeatures .SupportTLSRoute ,
29+ gatewayfeatures .SupportTLSRouteModeTerminate ,
30+ gatewayfeatures .SupportTLSRouteModeMixed ,
31+ }
32+
1833// SupportedFeatureNameSet returns the feature-name set this repository
1934// advertises through the in-repo conformance profile.
2035func SupportedFeatureNameSet () sets.Set [gatewayfeatures.FeatureName ] {
@@ -31,7 +46,7 @@ func SupportedFeatureNameSet() sets.Set[gatewayfeatures.FeatureName] {
3146 gatewayfeatures .SupportGatewayFrontendClientCertificateValidationInsecureFallback ,
3247 gatewayfeatures .SupportGatewayHTTPSListenerDetectMisdirectedRequests ,
3348 gatewayfeatures .SupportGatewayHTTPListenerIsolation ,
34- gatewayfeatures .SupportGatewayInfrastructurePropagation ,
49+ gatewayfeatures .SupportGatewayInfrastructurePropagation ,
3550 gatewayfeatures .SupportGatewayPort8080 ,
3651 gatewayfeatures .SupportGatewayStaticAddresses ,
3752 gatewayfeatures .SupportHTTPRoute ,
@@ -78,10 +93,32 @@ func SupportedFeatureNameSet() sets.Set[gatewayfeatures.FeatureName] {
7893 )
7994}
8095
96+ // SupportedFeatureNameSetForOptions returns the feature-name set advertised by
97+ // a control-plane instance with the provided runtime feature options.
98+ func SupportedFeatureNameSetForOptions (options FeatureOptions ) sets.Set [gatewayfeatures.FeatureName ] {
99+ out := SupportedFeatureNameSet ()
100+ if ! options .EnableExperimentalGateway {
101+ for _ , name := range experimentalGatewayFeatures {
102+ out .Delete (name )
103+ }
104+ }
105+ return out
106+ }
107+
81108// SupportedFeatureNames returns the feature-name set this repository currently
82109// advertises through the in-repo conformance profile.
83110func SupportedFeatureNames () []gatewayfeatures.FeatureName {
84- out := SupportedFeatureNameSet ().UnsortedList ()
111+ return sortedFeatureNamesFromSet (SupportedFeatureNameSet ())
112+ }
113+
114+ // SupportedFeatureNamesForOptions returns the sorted feature names advertised by
115+ // a control-plane instance with the provided runtime feature options.
116+ func SupportedFeatureNamesForOptions (options FeatureOptions ) []gatewayfeatures.FeatureName {
117+ return sortedFeatureNamesFromSet (SupportedFeatureNameSetForOptions (options ))
118+ }
119+
120+ func sortedFeatureNamesFromSet (items sets.Set [gatewayfeatures.FeatureName ]) []gatewayfeatures.FeatureName {
121+ out := items .UnsortedList ()
85122 sort .Slice (out , func (i , j int ) bool {
86123 return out [i ] < out [j ]
87124 })
@@ -92,6 +129,17 @@ func SupportedFeatureNames() []gatewayfeatures.FeatureName {
92129// GatewayClass status shape required by the Gateway API.
93130func SupportedFeatures () []gatewayv1.SupportedFeature {
94131 names := SupportedFeatureNames ()
132+ return supportedFeaturesFromNames (names )
133+ }
134+
135+ // SupportedFeaturesForOptions converts the runtime feature set into the
136+ // GatewayClass status shape required by the Gateway API.
137+ func SupportedFeaturesForOptions (options FeatureOptions ) []gatewayv1.SupportedFeature {
138+ names := SupportedFeatureNamesForOptions (options )
139+ return supportedFeaturesFromNames (names )
140+ }
141+
142+ func supportedFeaturesFromNames (names []gatewayfeatures.FeatureName ) []gatewayv1.SupportedFeature {
95143 out := make ([]gatewayv1.SupportedFeature , 0 , len (names ))
96144 for _ , name := range names {
97145 out = append (out , gatewayv1.SupportedFeature {
0 commit comments