You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/11/21 10:17:22 UTC

[GitHub] [apisix-ingress-controller] incubator4 opened a new pull request, #1471: feat: add control http method using kubernetes ingress by annotations

incubator4 opened a new pull request, #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471

   <!-- Please answer these questions before submitting a pull request -->
   
   ### Type of change:
   
   <!-- Please delete options that are not relevant. -->
   
   - [ ] Bugfix
   - [x] New feature provided
   - [ ] Improve performance
   - [ ] Backport patches
   
   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   Add new annotations `k8s.apisix.apache.org/http-allow-method` and `k8s.apisix.apache.org/http-block-method` to control which method could be passed or not
   <!--- If it fixes an open issue, please link to the issue here. -->
   This pr cause by issue #1463 
   
   ### Pre-submission checklist:
   
   <!--
   Please follow the requirements:
   1. Use Draft if the PR is not ready to be reviewed
   2. Test is required for the feat/fix PR, unless you have a good reason
   3. Doc is required for the feat PR
   4. Use a new commit to resolve review instead of `push -f`
   5. Use "request review" to notify the reviewer once you have resolved the review
   -->
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [x] Have you modified the corresponding document?
   * [x] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix-ingress-controller#community) first**
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on a diff in pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on code in PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#discussion_r1031998345


##########
pkg/providers/ingress/translation/annotations/plugins/http_method.go:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//	http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package plugins
+
+import (
+	"github.com/apache/apisix-ingress-controller/pkg/providers/ingress/translation/annotations"
+	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
+)
+
+type HttpMethod struct{}
+
+// NewHttpHandler creates a handler to convert annotations about
+// HttpMethod to APISIX cors plugin.
+func NewHttpMethodHandler() PluginAnnotationsHandler {
+	return &HttpMethod{}
+}
+
+func (h HttpMethod) PluginName() string {
+	return "response-rewrite"
+}
+
+func (h HttpMethod) Handle(e annotations.Extractor) (interface{}, error) {
+	var plugin apisixv1.ResponseRewriteConfig
+
+	allowMethods := e.GetStringsAnnotation(annotations.AnnotationsHttpAllowMethod)
+	blockMethods := e.GetStringsAnnotation(annotations.AnnotationsHttpBlockMethod)
+
+	plugin.StatusCode = 405
+	var methodExpr = []apisixv1.Expr{}
+
+	if len(allowMethods) > 0 {
+		//plugin.LuaRestyExpr = []interface{}{
+		//	[]interface{}{
+		//		"request_method", "!", "in", allowMethods,
+		//	},
+		//}
+		for _, method := range allowMethods {
+			methodExpr = append(methodExpr, apisixv1.Expr{StringVal: method})
+		}
+
+		plugin.LuaRestyExpr = []apisixv1.Expr{
+			{
+				ArrayVal: []apisixv1.Expr{
+					{StringVal: "request_method"},
+					{StringVal: "!"},
+					{StringVal: "in"},
+					{ArrayVal: methodExpr},
+				},
+			},
+		}
+
+	} else if len(blockMethods) > 0 {

Review Comment:
   This means that the two annotations are mutually exclusive. We should make it clear in the docs, thanks



##########
pkg/providers/ingress/translation/annotations/types.go:
##########
@@ -62,6 +62,10 @@ const (
 	AnnotationsAllowlistSourceRange = AnnotationsPrefix + "allowlist-source-range"
 	AnnotationsBlocklistSourceRange = AnnotationsPrefix + "blocklist-source-range"
 
+	// http-method plugin
+	AnnotationsHttpAllowMethod = AnnotationsPrefix + "http-allow-method"
+	AnnotationsHttpBlockMethod = AnnotationsPrefix + "http-block-method"

Review Comment:
   We should use plurals, right?
   
   `http-allow-methods` and `http-block-methods`



##########
docs/en/latest/concepts/annotations.md:
##########
@@ -99,6 +99,28 @@ k8s.apisix.apache.org/blocklist-source-range: "127.0.0.1,172.17.0.0/16"
 
 The default value is empty which means no IP addresses are blocked.
 
+## Allow http method
+
+This annotation can be used to specify which http method are allowed. Multiple methods can also be specified by separating them with commas.
+
+```yaml
+k8s.apisix.apache.org/http-allow-method: "GET,POST"
+```
+
+The default value is empty which means all methods are allowed.

Review Comment:
   I think it needs to be explained here that once this configuration is added, **it means that except for the allowed methods, the rest of the methods are not allowed**



##########
pkg/providers/ingress/translation/annotations/plugins/http_method.go:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//	http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package plugins
+
+import (
+	"github.com/apache/apisix-ingress-controller/pkg/providers/ingress/translation/annotations"
+	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
+)
+
+type HttpMethod struct{}
+
+// NewHttpHandler creates a handler to convert annotations about
+// HttpMethod to APISIX cors plugin.
+func NewHttpMethodHandler() PluginAnnotationsHandler {
+	return &HttpMethod{}
+}
+
+func (h HttpMethod) PluginName() string {
+	return "response-rewrite"
+}
+
+func (h HttpMethod) Handle(e annotations.Extractor) (interface{}, error) {
+	var plugin apisixv1.ResponseRewriteConfig
+
+	allowMethods := e.GetStringsAnnotation(annotations.AnnotationsHttpAllowMethod)
+	blockMethods := e.GetStringsAnnotation(annotations.AnnotationsHttpBlockMethod)
+
+	plugin.StatusCode = 405
+	var methodExpr = []apisixv1.Expr{}
+
+	if len(allowMethods) > 0 {
+		//plugin.LuaRestyExpr = []interface{}{

Review Comment:
   +1



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#issuecomment-1330064453

   CI failed. PTAL. 
   
   And please merge master branch to resolve conflicts. Thanks 


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#issuecomment-1331959195

   could you please merge master branch again?'
   due #1481 , CI jobs has been skipped, thanks!


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] lingsamuel commented on a diff in pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
lingsamuel commented on code in PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#discussion_r1029975960


##########
pkg/types/apisix/v1/plugin_types.go:
##########
@@ -177,3 +191,46 @@ func (p *Headers) DeepCopy() *Headers {
 	p.DeepCopyInto(out)
 	return out
 }
+
+// +k8s:deepcopy-gen=true
+type Expr struct {
+	StringVal string
+	ArrayVal  []Expr
+}
+
+func (e *Expr) MarshalJSON() ([]byte, error) {
+	if e.StringVal != "" {
+		return json.Marshal(e.StringVal)
+	} else {
+		return json.Marshal(e.ArrayVal)
+	}
+}
+
+func (expr *Expr) UnmarshalJSON(buf []byte) error {

Review Comment:
   It would be better to have a simple test for this function.



##########
pkg/providers/ingress/translation/annotations/plugins/http_method.go:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//	http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package plugins
+
+import (
+	"github.com/apache/apisix-ingress-controller/pkg/providers/ingress/translation/annotations"
+	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
+)
+
+type HttpMethod struct{}
+
+// NewHttpHandler creates a handler to convert annotations about
+// HttpMethod to APISIX cors plugin.
+func NewHttpMethodHandler() PluginAnnotationsHandler {
+	return &HttpMethod{}
+}
+
+func (h HttpMethod) PluginName() string {
+	return "response-rewrite"
+}
+
+func (h HttpMethod) Handle(e annotations.Extractor) (interface{}, error) {
+	var plugin apisixv1.ResponseRewriteConfig
+
+	allowMethods := e.GetStringsAnnotation(annotations.AnnotationsHttpAllowMethod)
+	blockMethods := e.GetStringsAnnotation(annotations.AnnotationsHttpBlockMethod)
+
+	plugin.StatusCode = 405
+	var methodExpr = []apisixv1.Expr{}
+
+	if len(allowMethods) > 0 {
+		//plugin.LuaRestyExpr = []interface{}{

Review Comment:
   I guess these lines should be deleted?



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] incubator4 commented on a diff in pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
incubator4 commented on code in PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#discussion_r1030723254


##########
pkg/types/apisix/v1/plugin_types.go:
##########
@@ -177,3 +191,46 @@ func (p *Headers) DeepCopy() *Headers {
 	p.DeepCopyInto(out)
 	return out
 }
+
+// +k8s:deepcopy-gen=true
+type Expr struct {
+	StringVal string
+	ArrayVal  []Expr
+}
+
+func (e *Expr) MarshalJSON() ([]byte, error) {
+	if e.StringVal != "" {
+		return json.Marshal(e.StringVal)
+	} else {
+		return json.Marshal(e.ArrayVal)
+	}
+}
+
+func (expr *Expr) UnmarshalJSON(buf []byte) error {

Review Comment:
   Hey, I was implementing a simple golang toolkit package called [go-resty-expr](https://github.com/incubator4/go-resty-expr) , 
   for generating expressions conforming to the [lua-resty-expr](https://github.com/api7/lua-resty-expr) specification.
   
   Also I've configured the corresponding tests and CI. May I use this package  in this ?



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 merged pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
tao12345666333 merged PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] incubator4 commented on a diff in pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
incubator4 commented on code in PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#discussion_r1030723254


##########
pkg/types/apisix/v1/plugin_types.go:
##########
@@ -177,3 +191,46 @@ func (p *Headers) DeepCopy() *Headers {
 	p.DeepCopyInto(out)
 	return out
 }
+
+// +k8s:deepcopy-gen=true
+type Expr struct {
+	StringVal string
+	ArrayVal  []Expr
+}
+
+func (e *Expr) MarshalJSON() ([]byte, error) {
+	if e.StringVal != "" {
+		return json.Marshal(e.StringVal)
+	} else {
+		return json.Marshal(e.ArrayVal)
+	}
+}
+
+func (expr *Expr) UnmarshalJSON(buf []byte) error {

Review Comment:
   Hey, I was implementing a simple golang toolkit package called [go-resty-expr](https://github.com/incubator4/go-resty-expr) , 
   for generating expressions conforming to the [lua-resty-expr](https://github.com/api7/lua-resty-expr) specification.
   
   Also I've configured the corresponding tests and CI. May I use this package  in this ?



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on a diff in pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on code in PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#discussion_r1032697323


##########
pkg/providers/ingress/translation/annotations/plugins/http_method.go:
##########
@@ -17,6 +17,8 @@ package plugins
 import (
 	"github.com/apache/apisix-ingress-controller/pkg/providers/ingress/translation/annotations"
 	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
+	"github.com/incubator4/go-resty-expr/expr"
+	"net/http"

Review Comment:
   please sort the imports.



##########
pkg/providers/ingress/translation/annotations/plugins/http_method_test.go:
##########
@@ -15,6 +15,8 @@
 package plugins
 
 import (
+	"github.com/incubator4/go-resty-expr/expr"
+	"net/http"

Review Comment:
   ditto



##########
test/e2e/suite-annotations/http_method.go:
##########
@@ -0,0 +1,198 @@
+package annotations
+
+import (
+	"fmt"
+	"net/http"
+	"time"
+
+	ginkgo "github.com/onsi/ginkgo/v2"
+	"github.com/stretchr/testify/assert"
+
+	"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+)
+
+var _ = ginkgo.Describe("suite-annotations: allow-http-methods annotations", func() {
+	s := scaffold.NewDefaultScaffold()
+
+	ginkgo.It("enable in ingress networking/v1", func() {
+		backendSvc, backendPort := s.DefaultHTTPBackend()
+		ing := fmt.Sprintf(`
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  annotations:
+    kubernetes.io/ingress.class: apisix
+    k8s.apisix.apache.org/allow-http-methods: POST,PUT
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /ip
+        pathType: Exact
+        backend:
+          service:
+            name: %s
+            port:
+              number: %d
+`, backendSvc, backendPort[0])
+		err := s.CreateResourceFromString(ing)
+		assert.Nil(ginkgo.GinkgoT(), err, "creating ingress")
+		time.Sleep(5 * time.Second)
+
+		resp := s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect()
+		resp.Status(http.StatusMethodNotAllowed)

Review Comment:
   We also need to check whether the methods that has been configured can work normally. (POST and PUT)



##########
test/e2e/suite-annotations/http_method.go:
##########
@@ -0,0 +1,198 @@
+package annotations
+
+import (
+	"fmt"
+	"net/http"
+	"time"
+
+	ginkgo "github.com/onsi/ginkgo/v2"
+	"github.com/stretchr/testify/assert"
+
+	"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+)
+
+var _ = ginkgo.Describe("suite-annotations: allow-http-methods annotations", func() {
+	s := scaffold.NewDefaultScaffold()
+
+	ginkgo.It("enable in ingress networking/v1", func() {
+		backendSvc, backendPort := s.DefaultHTTPBackend()
+		ing := fmt.Sprintf(`
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  annotations:
+    kubernetes.io/ingress.class: apisix
+    k8s.apisix.apache.org/allow-http-methods: POST,PUT
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /ip
+        pathType: Exact
+        backend:
+          service:
+            name: %s
+            port:
+              number: %d
+`, backendSvc, backendPort[0])
+		err := s.CreateResourceFromString(ing)
+		assert.Nil(ginkgo.GinkgoT(), err, "creating ingress")
+		time.Sleep(5 * time.Second)
+
+		resp := s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect()
+		resp.Status(http.StatusMethodNotAllowed)
+	})
+
+	ginkgo.It("enable in ingress networking/v1beta1", func() {
+		backendSvc, backendPort := s.DefaultHTTPBackend()
+		ing := fmt.Sprintf(`
+apiVersion: networking.k8s.io/v1beta1
+kind: Ingress
+metadata:
+  annotations:
+    kubernetes.io/ingress.class: apisix
+    k8s.apisix.apache.org/allow-http-methods: POST,PUT
+  name: ingress-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /ip
+        pathType: Exact
+        backend:
+          serviceName: %s
+          servicePort: %d
+`, backendSvc, backendPort[0])
+		err := s.CreateResourceFromString(ing)
+		assert.Nil(ginkgo.GinkgoT(), err, "creating ingress")
+		time.Sleep(5 * time.Second)
+
+		resp := s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect()
+		resp.Status(http.StatusMethodNotAllowed)
+	})
+
+	ginkgo.It("enable in ingress extensions/v1beta1", func() {
+		backendSvc, backendPort := s.DefaultHTTPBackend()
+		ing := fmt.Sprintf(`
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+  annotations:
+    kubernetes.io/ingress.class: apisix
+    k8s.apisix.apache.org/allow-http-methods: POST,PUT
+  name: ingress-extensions-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /ip
+        pathType: Exact
+        backend:
+          serviceName: %s
+          servicePort: %d
+`, backendSvc, backendPort[0])
+		err := s.CreateResourceFromString(ing)
+		assert.Nil(ginkgo.GinkgoT(), err, "creating ingress")
+		time.Sleep(5 * time.Second)
+
+		resp := s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect()
+		resp.Status(http.StatusMethodNotAllowed)
+	})
+})
+
+var _ = ginkgo.Describe("suite-annotations: blocklist-http-methods annotations", func() {
+	s := scaffold.NewDefaultScaffold()
+
+	ginkgo.It("enable in ingress networking/v1", func() {
+		backendSvc, backendPort := s.DefaultHTTPBackend()
+		ing := fmt.Sprintf(`
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  annotations:
+    kubernetes.io/ingress.class: apisix
+    k8s.apisix.apache.org/allow-http-methods: GET
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /ip
+        pathType: Exact
+        backend:
+          service:
+            name: %s
+            port:
+              number: %d
+`, backendSvc, backendPort[0])
+		err := s.CreateResourceFromString(ing)
+		assert.Nil(ginkgo.GinkgoT(), err, "creating ingress")
+		time.Sleep(5 * time.Second)
+
+		resp := s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect()
+		resp.Status(http.StatusMethodNotAllowed)

Review Comment:
   Also check whether it can work normally if it is not on the Block list.



##########
pkg/types/apisix/v1/plugin_types.go:
##########
@@ -16,7 +16,7 @@ package v1
 
 import (
 	"encoding/json"
-	"fmt"
+	"github.com/incubator4/go-resty-expr/expr"

Review Comment:
   ditto



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] codecov-commenter commented on pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#issuecomment-1322879593

   # [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1471?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1471](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1471?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a54f021) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/ec88b49cdc3164c44cef990482fc29ca7490aa3c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ec88b49) will **increase** coverage by `0.21%`.
   > The diff coverage is `88.23%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1471      +/-   ##
   ==========================================
   + Coverage   41.16%   41.38%   +0.21%     
   ==========================================
     Files          82       83       +1     
     Lines        7322     7356      +34     
   ==========================================
   + Hits         3014     3044      +30     
   - Misses       3956     3960       +4     
     Partials      352      352              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ingress/translation/annotations/plugins/plugins.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1471/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL3Byb3ZpZGVycy9pbmdyZXNzL3RyYW5zbGF0aW9uL2Fubm90YXRpb25zL3BsdWdpbnMvcGx1Z2lucy5nbw==) | `0.00% <ø> (ø)` | |
   | [...ess/translation/annotations/plugins/http\_method.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1471/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL3Byb3ZpZGVycy9pbmdyZXNzL3RyYW5zbGF0aW9uL2Fubm90YXRpb25zL3BsdWdpbnMvaHR0cF9tZXRob2QuZ28=) | `88.23% <88.23%> (ø)` | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] incubator4 commented on a diff in pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
incubator4 commented on code in PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#discussion_r1031098279


##########
pkg/types/apisix/v1/plugin_types.go:
##########
@@ -177,3 +191,46 @@ func (p *Headers) DeepCopy() *Headers {
 	p.DeepCopyInto(out)
 	return out
 }
+
+// +k8s:deepcopy-gen=true
+type Expr struct {
+	StringVal string
+	ArrayVal  []Expr
+}
+
+func (e *Expr) MarshalJSON() ([]byte, error) {
+	if e.StringVal != "" {
+		return json.Marshal(e.StringVal)
+	} else {
+		return json.Marshal(e.ArrayVal)
+	}
+}
+
+func (expr *Expr) UnmarshalJSON(buf []byte) error {

Review Comment:
   > It would be better to have a simple test for this function.
   
   Hey, I was implementing a simple golang toolkit package called [go-resty-expr](https://github.com/incubator4/go-resty-expr) , 
   for generating expressions conforming to the [lua-resty-expr](https://github.com/api7/lua-resty-expr) specification.
   
   Also I've configured the corresponding tests and CI. May I use this package  in this ?



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] incubator4 commented on pull request #1471: feat: add control http method using kubernetes ingress by annotations

Posted by GitBox <gi...@apache.org>.
incubator4 commented on PR #1471:
URL: https://github.com/apache/apisix-ingress-controller/pull/1471#issuecomment-1331973167

   > could you please merge master branch again?' due #1481 , CI jobs has been skipped, thanks!
   
   Already did !


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org