lingsamuel commented on code in PR #1103:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/1103#discussion_r910610427


##########
test/e2e/scaffold/scaffold.go:
##########
@@ -583,11 +606,38 @@ func (s *Scaffold) CreateVersionedApisixPluginConfig(yml 
string) error {
        return s.CreateResourceFromString(ac)
 }
 
-func (s *Scaffold) CreateVersionedApisixRoute(yml string) error {
-       if !strings.Contains(yml, "kind: ApisixRoute") {
-               return errors.New("not a ApisixRoute")
+func (s *Scaffold) CreateVersionedApisixResource(yml string) error {
+       if strings.Contains(yml, "kind: ApisixRoute") {
+               ar := s.replaceApiVersion(yml, s.opts.APISIXRouteVersion)
+               return s.CreateResourceFromString(ar)
+       }
+       if strings.Contains(yml, "kind: ApisixConsumer") {
+               ac := s.replaceApiVersion(yml, s.opts.APISIXConsumerVersion)
+               return s.CreateResourceFromString(ac)
+       }
+       if strings.Contains(yml, "kind: ApisixPluginConfig") {
+               apc := s.replaceApiVersion(yml, 
s.opts.ApisixPluginConfigVersion)
+               return s.CreateResourceFromString(apc)
        }
+       return errors.New("this resource does not support")
+}
 
-       ac := s.replaceApiVersion(yml, s.opts.APISIXRouteVersion)
-       return s.CreateResourceFromString(ac)
+func (s *Scaffold) CreateVersionedApisixResourceWithNamespace(yml, namespace 
string) error {
+       if strings.Contains(yml, "kind: ApisixRoute") {
+               ar := s.replaceApiVersion(yml, s.opts.APISIXRouteVersion)
+               return s.CreateResourceFromStringWithNamespace(ar, namespace)
+       }
+       if strings.Contains(yml, "kind: ApisixConsumer") {
+               ac := s.replaceApiVersion(yml, s.opts.APISIXConsumerVersion)
+               return s.CreateResourceFromStringWithNamespace(ac, namespace)
+       }
+       if strings.Contains(yml, "kind: ApisixPluginConfig") {
+               apc := s.replaceApiVersion(yml, 
s.opts.ApisixPluginConfigVersion)
+               return s.CreateResourceFromStringWithNamespace(apc, namespace)
+       }
+       return errors.New("this resource does not support")

Review Comment:
   same



##########
test/e2e/scaffold/scaffold.go:
##########
@@ -583,11 +606,38 @@ func (s *Scaffold) CreateVersionedApisixPluginConfig(yml 
string) error {
        return s.CreateResourceFromString(ac)
 }
 
-func (s *Scaffold) CreateVersionedApisixRoute(yml string) error {
-       if !strings.Contains(yml, "kind: ApisixRoute") {
-               return errors.New("not a ApisixRoute")
+func (s *Scaffold) CreateVersionedApisixResource(yml string) error {
+       if strings.Contains(yml, "kind: ApisixRoute") {
+               ar := s.replaceApiVersion(yml, s.opts.APISIXRouteVersion)
+               return s.CreateResourceFromString(ar)
+       }
+       if strings.Contains(yml, "kind: ApisixConsumer") {
+               ac := s.replaceApiVersion(yml, s.opts.APISIXConsumerVersion)
+               return s.CreateResourceFromString(ac)
+       }
+       if strings.Contains(yml, "kind: ApisixPluginConfig") {
+               apc := s.replaceApiVersion(yml, 
s.opts.ApisixPluginConfigVersion)
+               return s.CreateResourceFromString(apc)
        }
+       return errors.New("this resource does not support")

Review Comment:
   would be better to show what kind of resource it is. Use regex to extract 
the resource kind and return error in default branch of switch/case.



-- 
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