Revolyssup commented on code in PR #2548:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2548#discussion_r2332687272


##########
internal/adc/translator/httproute.go:
##########
@@ -129,6 +131,50 @@ func (t *Translator) 
fillPluginFromURLRewriteFilter(plugins adctypes.Plugins, ur
        }
 }
 
+func (t *Translator) fillPluginFromHTTPCORSFilter(plugins adctypes.Plugins, 
cors *gatewayv1.HTTPCORSFilter) {
+       pluginName := adctypes.PluginCORS
+       obj := plugins[pluginName]
+       var plugin *adctypes.CorsConfig
+       if obj == nil {
+               plugin = &adctypes.CorsConfig{}
+               plugins[pluginName] = plugin
+       } else {
+               plugin = obj.(*adctypes.CorsConfig)
+       }
+
+       if len(cors.AllowOrigins) != 0 {
+               origins := make([]string, 0)
+               for _, allowOrigin := range cors.AllowOrigins {
+                       origins = append(origins, string(allowOrigin))
+               }
+               plugin.AllowOrigins = strings.Join(origins, ",")
+       }
+
+       if len(cors.AllowHeaders) != 0 {
+               headers := make([]string, 0)
+               for _, allowHeader := range cors.AllowHeaders {
+                       headers = append(headers, string(allowHeader))
+               }
+               plugin.AllowHeaders = strings.Join(headers, ",")
+       }
+
+       if len(cors.AllowMethods) != 0 {
+               methods := make([]string, 0)
+               for _, allowMethod := range cors.AllowMethods {
+                       methods = append(methods, string(allowMethod))
+               }
+               plugin.AllowHeaders = strings.Join(methods, ",")

Review Comment:
   Sorry this was a type. Headers and Methods were not being asserted in tests 
so it was missed. I have fixed it and added assertion for headers and methods.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to