Skip to content

Commit 20ed67d

Browse files
committed
support cors output without experimental flag
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
1 parent bb79f14 commit 20ed67d

4 files changed

Lines changed: 5 additions & 8 deletions

File tree

cmd/print.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type PrintRunner struct {
8585
// Defaults to "standard".
8686
emitter string
8787

88-
// allowExperimentalGatewayAPI indicates whether Experimental Gateway API features (like CORS, URLRewrite) should be included in the output.
88+
// allowExperimentalGatewayAPI indicates whether Experimental Gateway API features (like URLRewrite) should be included in the output.
8989
allowExperimentalGatewayAPI bool
9090
}
9191

@@ -421,7 +421,7 @@ if specified with --namespace.`)
421421
cmd.Flags().StringSliceVar(&pr.providers, "providers", []string{},
422422
fmt.Sprintf("If present, the tool will try to convert only resources related to the specified providers, supported values are %v.", i2gw.GetSupportedProviders()))
423423

424-
cmd.Flags().BoolVar(&pr.allowExperimentalGatewayAPI, "allow-experimental-gw-api", false, "If present, the tool will include Experimental Gateway API fields (e.g. CORS, URLRewrite) in the output. Default is false.")
424+
cmd.Flags().BoolVar(&pr.allowExperimentalGatewayAPI, "allow-experimental-gw-api", false, "If present, the tool will include Experimental Gateway API fields (e.g. URLRewrite) in the output. Default is false.")
425425

426426
pr.providerSpecificFlags = make(map[string]*string)
427427
for provider, flags := range i2gw.GetProviderSpecificFlagDefinitions() {

pkg/i2gw/emitter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ type EmitterName string
6060
type EmitterConstructor func(conf *EmitterConf) Emitter
6161

6262
type EmitterConf struct {
63-
// AllowExperimentalGatewayAPI indicates whether Experimental Gateway API features (like CORS, URLRewrite) should be included in the output.
63+
// AllowExperimentalGatewayAPI indicates whether Experimental Gateway API features (like URLRewrite) should be included in the output.
6464
AllowExperimentalGatewayAPI bool
6565
}

pkg/i2gw/emitters/common_emitter/emitter.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ func applyPathRewrites(ir *emitterir.EmitterIR) {
7272
}
7373

7474
func (e *Emitter) applyCorsPolicies(ir *emitterir.EmitterIR) {
75-
if e.conf != nil && !e.conf.AllowExperimentalGatewayAPI {
76-
return
77-
}
7875
for key, routeCtx := range ir.HTTPRoutes {
7976
for ruleIdx, policy := range routeCtx.CorsPolicyByRuleIdx {
8077
if policy == nil {

pkg/i2gw/emitters/common_emitter/emitter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func TestEmitCORSFiltering(t *testing.T) {
164164
name: "experimental denied + cors in sidecar -> cors NOT added",
165165
allowExperimental: false,
166166
corsInSidecar: &gatewayv1.HTTPCORSFilter{},
167-
expectedFiltersCount: 0,
167+
expectedFiltersCount: 1,
168168
},
169169
{
170170
name: "other filters preserved regardless of flag",
@@ -173,7 +173,7 @@ func TestEmitCORSFiltering(t *testing.T) {
173173
{Type: gatewayv1.HTTPRouteFilterRequestHeaderModifier},
174174
},
175175
corsInSidecar: &gatewayv1.HTTPCORSFilter{},
176-
expectedFiltersCount: 1, // only header modifier
176+
expectedFiltersCount: 2, // only header modifier
177177
},
178178
}
179179

0 commit comments

Comments
 (0)