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/04/20 10:10:05 UTC

[GitHub] [apisix-ingress-controller] AlinsRan opened a new pull request, #975: update an redirect annotation to the ingress resourceRedirect annotation

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

   <!-- Please answer these questions before submitting a pull request -->
   
   ### Type of change:
   
   <!-- Please delete options that are not relevant. -->
   
   - [ ] Bugfix
   - [ ] 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? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   
   ### 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
   -->
   
   * [ ] Did you explain what problem does this PR solve? Or what new features have been added?
   * [ ] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] 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 #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -37,8 +41,15 @@ func (r *redirect) PluginName() string {
 func (r *redirect) Handle(e Extractor) (interface{}, error) {
 	var plugin apisixv1.RedirectConfig
 	plugin.HttpToHttps = e.GetBoolAnnotation(_httpToHttps)
+	plugin.URI = e.GetStringAnnotation(_uri)
+
+	retCode, err := strconv.Atoi(e.GetStringAnnotation(_retCode))
 	// To avoid empty redirect plugin config, adding the check about the redirect.
-	if plugin.HttpToHttps {
+	if err == nil {
+		plugin.RetCode = retCode
+		return &plugin, nil

Review Comment:
   yes, if there is no redirect target, then how can there be a redirect status code?



-- 
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 #975: feat: update an redirect annotation for ingress resource

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


##########
test/e2e/suite-annotations/redirect.go:
##########
@@ -119,4 +120,203 @@ spec:
 		resp.Status(http.StatusMovedPermanently)
 		resp.Header("Location").Equal("https://httpbin.org/sample")
 	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-extensions-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect external link 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/permanent-redirect: "https://httpbin.org/get"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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)

Review Comment:
   We can keep it that way for now. After that, unified processing will be carried out. Our current test cases contain many similar sleep behaviors.



-- 
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] jwrookie commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -37,8 +41,13 @@ func (r *redirect) PluginName() string {
 func (r *redirect) Handle(e Extractor) (interface{}, error) {
 	var plugin apisixv1.RedirectConfig
 	plugin.HttpToHttps = e.GetBoolAnnotation(_httpToHttps)
+	plugin.URI = e.GetStringAnnotation(_uri)
+	retCode, err := strconv.Atoi(e.GetStringAnnotation(_retCode))

Review Comment:
   We should handle the err when err != nil
   If there is special logic, we should add comments that the err returned by this method is always nil



##########
test/e2e/suite-annotations/redirect.go:
##########
@@ -119,4 +120,203 @@ spec:
 		resp.Status(http.StatusMovedPermanently)
 		resp.Header("Location").Equal("https://httpbin.org/sample")
 	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-extensions-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect external link 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/permanent-redirect: "https://httpbin.org/get"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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)

Review Comment:
   How about use `EnsureNumApisixUpstreamsCreated` and `EnsureNumApisixRoutesCreated` insted of `Sleep`



##########
test/e2e/suite-annotations/redirect.go:
##########
@@ -119,4 +120,203 @@ spec:
 		resp.Status(http.StatusMovedPermanently)
 		resp.Header("Location").Equal("https://httpbin.org/sample")
 	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-extensions-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect external link 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/permanent-redirect: "https://httpbin.org/get"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		url := resp.Header("Location").Equal("https://httpbin.org/get").Raw()
+
+		body := httpexpect.New(ginkgo.GinkgoT(), url).GET("").Expect().Status(http.StatusOK).Body().Raw()
+		assert.Contains(ginkgo.GinkgoT(), body, "https://httpbin.org/get")
+	})
+
+	ginkgo.It("redirect permanent-redirect external link 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/permanent-redirect: "https://httpbin.org/get"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		url := resp.Header("Location").Equal("https://httpbin.org/get").Raw()
+
+		body := httpexpect.New(ginkgo.GinkgoT(), url).GET("").Expect().Status(http.StatusOK).Body().Raw()
+		assert.Contains(ginkgo.GinkgoT(), body, "https://httpbin.org/get")
+	})
+
+	ginkgo.It("redirect permanent-redirect external link 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/permanent-redirect: "https://httpbin.org/get"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-extensions-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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)

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] AlinsRan commented on pull request #975: feat: update an redirect annotation for ingress resource

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

   > @AlinsRan Hi, some test error, pls have a check
   
   This error is `suite-plugins`, but I only modified `suite-annotations`. 
   I again push?


-- 
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] jwrookie commented on pull request #975: feat: update an redirect annotation for ingress resource

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

   @AlinsRan Hi, some test error, pls have a check


-- 
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] AlinsRan commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
test/e2e/suite-annotations/redirect.go:
##########
@@ -119,4 +120,203 @@ spec:
 		resp.Status(http.StatusMovedPermanently)
 		resp.Header("Location").Equal("https://httpbin.org/sample")
 	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-extensions-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect external link 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/permanent-redirect: "https://httpbin.org/get"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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)

Review Comment:
   This is an ingress resource. Are you sure can replace?



-- 
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] AlinsRan commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -15,11 +15,15 @@
 package annotations
 
 import (
+	"strconv"
+
 	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 const (
-	_httpToHttps = AnnotationsPrefix + "http-to-https"
+	_httpToHttps           = AnnotationsPrefix + "http-to-https"
+	_permanentRedirect     = AnnotationsPrefix + "permanent-redirect"
+	_permanentRedirectCode = AnnotationsPrefix + "permanent-redirect-code"

Review Comment:
   Got it.



-- 
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 #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -15,11 +15,15 @@
 package annotations
 
 import (
+	"strconv"
+
 	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 const (
 	_httpToHttps = AnnotationsPrefix + "http-to-https"
+	_uri         = AnnotationsPrefix + "uri"
+	_retCode     = AnnotationsPrefix + "ret_code"

Review Comment:
   I tend to use
   
   `k8s.apisix.apache.org/permanent-redirect` for uri
   `k8s.apisix.apache.org/permanent-redirect-code` for ret_code



-- 
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] AlinsRan commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -37,8 +41,15 @@ func (r *redirect) PluginName() string {
 func (r *redirect) Handle(e Extractor) (interface{}, error) {
 	var plugin apisixv1.RedirectConfig
 	plugin.HttpToHttps = e.GetBoolAnnotation(_httpToHttps)
+	plugin.URI = e.GetStringAnnotation(_uri)
+
+	retCode, err := strconv.Atoi(e.GetStringAnnotation(_retCode))
 	// To avoid empty redirect plugin config, adding the check about the redirect.
-	if plugin.HttpToHttps {
+	if err == nil {
+		plugin.RetCode = retCode
+		return &plugin, nil

Review Comment:
   Cannot be used alone `ret_code`? the `ret_ code 'needs to be used with' uri ' ? If so, that's not right.



-- 
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] AlinsRan commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -37,8 +41,15 @@ func (r *redirect) PluginName() string {
 func (r *redirect) Handle(e Extractor) (interface{}, error) {
 	var plugin apisixv1.RedirectConfig
 	plugin.HttpToHttps = e.GetBoolAnnotation(_httpToHttps)
+	plugin.URI = e.GetStringAnnotation(_uri)
+
+	retCode, err := strconv.Atoi(e.GetStringAnnotation(_retCode))
 	// To avoid empty redirect plugin config, adding the check about the redirect.
-	if plugin.HttpToHttps {
+	if err == nil {
+		plugin.RetCode = retCode
+		return &plugin, nil

Review Comment:
   Cannot be used alone `ret_code`? the `ret_ code` needs to be used with `uri` ? If so, that's not right.



-- 
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] jwrookie commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
test/e2e/suite-annotations/redirect.go:
##########
@@ -119,4 +120,203 @@ spec:
 		resp.Status(http.StatusMovedPermanently)
 		resp.Header("Location").Equal("https://httpbin.org/sample")
 	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect 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/permanent-redirect: "/anything$uri"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-extensions-v1beta1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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.StatusPermanentRedirect)
+		resp.Header("Location").Equal("/anything/ip")
+	})
+
+	ginkgo.It("redirect permanent-redirect external link 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/permanent-redirect: "https://httpbin.org/get"
+    k8s.apisix.apache.org/permanent-redirect-code: "308"
+  name: ingress-v1
+spec:
+  rules:
+  - host: httpbin.org
+    http:
+      paths:
+      - path: /*
+        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)

Review Comment:
   got it



-- 
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] tokers commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -15,11 +15,15 @@
 package annotations
 
 import (
+	"strconv"
+
 	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 const (
-	_httpToHttps = AnnotationsPrefix + "http-to-https"
+	_httpToHttps           = AnnotationsPrefix + "http-to-https"
+	_permanentRedirect     = AnnotationsPrefix + "permanent-redirect"
+	_permanentRedirectCode = AnnotationsPrefix + "permanent-redirect-code"

Review Comment:
   I mean, we should only allow users configuring `301` or `308` here. If I configure a `302` code here, it doesn't comply the HTTP semantic, because `302` is a "temporarily" redirect, but what we want is "permanent".



-- 
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] AlinsRan commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -15,11 +15,15 @@
 package annotations
 
 import (
+	"strconv"
+
 	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 const (
-	_httpToHttps = AnnotationsPrefix + "http-to-https"
+	_httpToHttps           = AnnotationsPrefix + "http-to-https"
+	_permanentRedirect     = AnnotationsPrefix + "permanent-redirect"
+	_permanentRedirectCode = AnnotationsPrefix + "permanent-redirect-code"

Review Comment:
   Do you mean to add test cases for other status codes?



-- 
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 #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -37,8 +41,15 @@ func (r *redirect) PluginName() string {
 func (r *redirect) Handle(e Extractor) (interface{}, error) {
 	var plugin apisixv1.RedirectConfig
 	plugin.HttpToHttps = e.GetBoolAnnotation(_httpToHttps)
+	plugin.URI = e.GetStringAnnotation(_uri)
+
+	retCode, err := strconv.Atoi(e.GetStringAnnotation(_retCode))
 	// To avoid empty redirect plugin config, adding the check about the redirect.
-	if plugin.HttpToHttps {
+	if err == nil {
+		plugin.RetCode = retCode
+		return &plugin, nil

Review Comment:
   Why return it directly?



##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -37,8 +41,15 @@ func (r *redirect) PluginName() string {
 func (r *redirect) Handle(e Extractor) (interface{}, error) {
 	var plugin apisixv1.RedirectConfig
 	plugin.HttpToHttps = e.GetBoolAnnotation(_httpToHttps)
+	plugin.URI = e.GetStringAnnotation(_uri)
+

Review Comment:
   plz remove this blank line 



-- 
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 #975: feat: update an redirect annotation for ingress resource

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


-- 
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] AlinsRan commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
test/e2e/suite-annotations/redirect.go:
##########
@@ -90,6 +90,39 @@ spec:
 		resp.Header("Location").Equal("https://httpbin.org/sample")
 	})
 
+	ginkgo.It("redirect permanent-redirect in ingress networking/v1", func() {

Review Comment:
   ok



-- 
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 #975: feat: update an redirect annotation for ingress resource

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


##########
test/e2e/suite-annotations/redirect.go:
##########
@@ -90,6 +90,39 @@ spec:
 		resp.Header("Location").Equal("https://httpbin.org/sample")
 	})
 
+	ginkgo.It("redirect permanent-redirect in ingress networking/v1", func() {

Review Comment:
   We need more test cases to cover `extensions/v1beta1`  and `networking/v1beta1` Ingress.
   
   And should increase the verification of the redirected result.
   
   For example, redirect it to https://httpbin.org/get to check if the result is as expected



-- 
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 #975: update an redirect annotation to the ingress resourceRedirect annotation

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

   # [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/975?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 [#975](https://codecov.io/gh/apache/apisix-ingress-controller/pull/975?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4412286) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/0f4391a87a38ae9a2c61a0cea717cb831fc55506?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0f4391a) will **decrease** coverage by `0.02%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #975      +/-   ##
   ==========================================
   - Coverage   31.91%   31.89%   -0.03%     
   ==========================================
     Files          73       73              
     Lines        7953     7958       +5     
   ==========================================
     Hits         2538     2538              
   - Misses       5139     5144       +5     
     Partials      276      276              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/975?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [pkg/kube/translation/annotations/redirect.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/975/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-cGtnL2t1YmUvdHJhbnNsYXRpb24vYW5ub3RhdGlvbnMvcmVkaXJlY3QuZ28=) | `0.00% <0.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/975?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/975?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [0f4391a...4412286](https://codecov.io/gh/apache/apisix-ingress-controller/pull/975?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?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] AlinsRan commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -15,11 +15,15 @@
 package annotations
 
 import (
+	"strconv"
+
 	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 const (
 	_httpToHttps = AnnotationsPrefix + "http-to-https"
+	_uri         = AnnotationsPrefix + "uri"
+	_retCode     = AnnotationsPrefix + "ret_code"

Review Comment:
   got it, I think so, too.



-- 
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] tokers commented on a diff in pull request #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -15,11 +15,15 @@
 package annotations
 
 import (
+	"strconv"
+
 	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 const (
-	_httpToHttps = AnnotationsPrefix + "http-to-https"
+	_httpToHttps           = AnnotationsPrefix + "http-to-https"
+	_permanentRedirect     = AnnotationsPrefix + "permanent-redirect"
+	_permanentRedirectCode = AnnotationsPrefix + "permanent-redirect-code"

Review Comment:
   IMHO since we want to make a permanent redirect, only codes `301` and `308` are allowed, in such a case, let users specify a custom HTTP status code that doesn't comply with the HTTP semantic.



-- 
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 #975: feat: update an redirect annotation for ingress resource

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


##########
pkg/kube/translation/annotations/redirect.go:
##########
@@ -15,11 +15,15 @@
 package annotations
 
 import (
+	"strconv"
+
 	apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 const (
-	_httpToHttps = AnnotationsPrefix + "http-to-https"
+	_httpToHttps           = AnnotationsPrefix + "http-to-https"
+	_permanentRedirect     = AnnotationsPrefix + "permanent-redirect"
+	_permanentRedirectCode = AnnotationsPrefix + "permanent-redirect-code"

Review Comment:
   @tokers  @AlinsRan  According to [RFC 7231](https://www.rfc-editor.org/rfc/rfc7231.html)  Status codes between 300 and 308 can indicate redirection. 
   
   Considering that we will also support temporary redirection, but adding a specific implementation for it alone is not of much value, here I suggest to merge it directly and modify this annotation to `http-redirect` and `http-redirect-code` , the corresponding verification logic is, if not configured, the default is `http.StatusMovedPermanently`, the allowed value is between `http.StatusMultipleChoices` and `http.StatusPermanentRedirect`.
   
   



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