You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by li...@apache.org on 2023/03/06 08:48:11 UTC
[apisix-ingress-controller] branch master updated: feat: sync plugin-config labels to apisix (#1538)
This is an automated email from the ASF dual-hosted git repository.
lingsamuel 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 4cd8ad52 feat: sync plugin-config labels to apisix (#1538)
4cd8ad52 is described below
commit 4cd8ad52dcc18dcd874d663fac5e31eebe417720
Author: Abhishek Choudhary <sh...@gmail.com>
AuthorDate: Mon Mar 6 14:17:56 2023 +0530
feat: sync plugin-config labels to apisix (#1538)
* feat: sync plugin-config labels to apisix
* test-e2e: add e2e test cases for plugin config
---
.../apisix/translation/apisix_pluginconfig.go | 3 ++
test/e2e/suite-chore/consistency.go | 41 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/pkg/providers/apisix/translation/apisix_pluginconfig.go b/pkg/providers/apisix/translation/apisix_pluginconfig.go
index e3da673b..a04a9788 100644
--- a/pkg/providers/apisix/translation/apisix_pluginconfig.go
+++ b/pkg/providers/apisix/translation/apisix_pluginconfig.go
@@ -104,6 +104,9 @@ func (t *translator) TranslatePluginConfigV2(config *configv2.ApisixPluginConfig
}
}
pc := apisixv1.NewDefaultPluginConfig()
+ for k, v := range config.ObjectMeta.Labels {
+ pc.Metadata.Labels[k] = v
+ }
pc.Name = apisixv1.ComposePluginConfigName(config.Namespace, config.Name)
pc.ID = id.GenID(pc.Name)
pc.Plugins = pluginMap
diff --git a/test/e2e/suite-chore/consistency.go b/test/e2e/suite-chore/consistency.go
index e2a543e4..c4e03f3a 100644
--- a/test/e2e/suite-chore/consistency.go
+++ b/test/e2e/suite-chore/consistency.go
@@ -321,3 +321,44 @@ spec:
}))
})
})
+
+var _ = ginkgo.Describe("suite-chore: apisix plugin config labels sync", func() {
+ suites := func(s *scaffold.Scaffold) {
+ ginkgo.JustBeforeEach(func() {
+ labels := map[string]string{"key": "value", "foo": "bar"}
+ apc := `
+apiVersion: apisix.apache.org/v2
+kind: ApisixPluginConfig
+metadata:
+ name: my-echo
+ labels:
+ key: value
+ foo: bar
+spec:
+ plugins:
+ - name: echo
+ enable: true
+ config:
+ body: "my-echo"
+`
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(apc))
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixPluginConfigCreated(1), "Checking number of plugin configs")
+
+ pluginConfigs, _ := s.ListApisixPluginConfig()
+ assert.Len(ginkgo.GinkgoT(), pluginConfigs, 1)
+ // check if labels exists
+ for _, pluginConfig := range pluginConfigs {
+ eq := reflect.DeepEqual(pluginConfig.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,
+ }))
+ })
+})