You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by zh...@apache.org on 2023/04/06 08:20:25 UTC
[apisix-ingress-controller] branch master updated: feat: sync apisix upstream labels (#1553)
This is an automated email from the ASF dual-hosted git repository.
zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push:
new bacb8f81 feat: sync apisix upstream labels (#1553)
bacb8f81 is described below
commit bacb8f8111656b3a765dc71352f43ea244de06f1
Author: Abhishek Choudhary <sh...@gmail.com>
AuthorDate: Thu Apr 6 13:50:19 2023 +0530
feat: sync apisix upstream labels (#1553)
---
.../apisix/translation/apisix_upstream.go | 3 ++
test/e2e/suite-chore/consistency.go | 39 ++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/pkg/providers/apisix/translation/apisix_upstream.go b/pkg/providers/apisix/translation/apisix_upstream.go
index ad665115..9578694b 100644
--- a/pkg/providers/apisix/translation/apisix_upstream.go
+++ b/pkg/providers/apisix/translation/apisix_upstream.go
@@ -141,6 +141,9 @@ func (t *translator) translateExternalApisixUpstream(namespace, upstream string)
if err != nil {
return nil, err
}
+ for k, v := range au.ObjectMeta.Labels {
+ ups.Metadata.Labels[k] = v
+ }
ups.Name = apisixv1.ComposeExternalUpstreamName(namespace, upstream)
ups.ID = id.GenID(ups.Name)
diff --git a/test/e2e/suite-chore/consistency.go b/test/e2e/suite-chore/consistency.go
index c4e03f3a..a16a6fe7 100644
--- a/test/e2e/suite-chore/consistency.go
+++ b/test/e2e/suite-chore/consistency.go
@@ -362,3 +362,42 @@ spec:
}))
})
})
+
+var _ = ginkgo.Describe("suite-chore: apisix upstream labels sync", func() {
+ suites := func(s *scaffold.Scaffold) {
+ ginkgo.JustBeforeEach(func() {
+ labels := map[string]string{"key": "value", "foo": "bar"}
+ au := `
+apiVersion: apisix.apache.org/v2
+kind: ApisixUpstream
+metadata:
+ name: foo
+ labels:
+ foo: bar
+ key: value
+spec:
+ timeout:
+ read: 10s
+ send: 10s
+`
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(au))
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(1), "Checking number of upstreams")
+
+ upstreams, _ := s.ListApisixUpstreams()
+ assert.Len(ginkgo.GinkgoT(), upstreams, 1)
+ // check if labels exists
+ for _, route := range upstreams {
+ eq := reflect.DeepEqual(route.Metadata.Labels, labels)
+ assert.True(ginkgo.GinkgoT(), eq)
+ }
+ })
+ }
+
+ ginkgo.Describe("suite-chore: scaffold v2", func() {
+ suites(scaffold.NewScaffold(&scaffold.Options{
+ Name: "sync",
+ IngressAPISIXReplicas: 1,
+ ApisixResourceVersion: scaffold.ApisixResourceVersion().V2,
+ }))
+ })
+})