diff --git a/addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml b/addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml index 64d46da06..8c7718c8c 100644 --- a/addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml +++ b/addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml @@ -203,6 +203,9 @@ spec: - path type: object type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map type: description: |- Type defines the option of how status can be returned. diff --git a/test/integration/api/manifestwork_test.go b/test/integration/api/manifestwork_test.go index 49c9224d0..0df5660f3 100644 --- a/test/integration/api/manifestwork_test.go +++ b/test/integration/api/manifestwork_test.go @@ -214,7 +214,7 @@ var _ = ginkgo.Describe("ManifestWork API test", func() { gomega.Expect(err).To(gomega.HaveOccurred()) }) - ginkgo.It("set feedback rule", func() { + ginkgo.It("set well known status feedback rule", func() { work := &workv1.ManifestWork{ ObjectMeta: metav1.ObjectMeta{ Name: manifestWorkName, @@ -239,5 +239,69 @@ var _ = ginkgo.Describe("ManifestWork API test", func() { Create(context.TODO(), work, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) }) + + ginkgo.It("set jsonpath feedback rule", func() { + work := &workv1.ManifestWork{ + ObjectMeta: metav1.ObjectMeta{ + Name: manifestWorkName, + }, + Spec: workv1.ManifestWorkSpec{ + ManifestConfigs: []workv1.ManifestConfigOption{ + { + ResourceIdentifier: workv1.ResourceIdentifier{ + Resource: "foo", + Name: "test", + Namespace: "testns", + }, + FeedbackRules: []workv1.FeedbackRule{ + { + Type: workv1.JSONPathsType, + JsonPaths: []workv1.JsonPath{ + {Name: "Replica", Path: ".spec.replicas"}, + {Name: "StatusReplica", Path: ".status.replicas"}, + }, + }, + }, + }, + }, + }, + } + + _, err := hubWorkClient.WorkV1().ManifestWorks(testNamespace). + Create(context.TODO(), work, metav1.CreateOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("set feedback rule with same jsonpath name", func() { + work := &workv1.ManifestWork{ + ObjectMeta: metav1.ObjectMeta{ + Name: manifestWorkName, + }, + Spec: workv1.ManifestWorkSpec{ + ManifestConfigs: []workv1.ManifestConfigOption{ + { + ResourceIdentifier: workv1.ResourceIdentifier{ + Resource: "foo", + Name: "test", + Namespace: "testns", + }, + FeedbackRules: []workv1.FeedbackRule{ + { + Type: workv1.JSONPathsType, + JsonPaths: []workv1.JsonPath{ + {Name: "Replica", Path: ".spec.replicas"}, + {Name: "Replica", Path: ".status.replicas"}, + }, + }, + }, + }, + }, + }, + } + + _, err := hubWorkClient.WorkV1().ManifestWorks(testNamespace). + Create(context.TODO(), work, metav1.CreateOptions{}) + gomega.Expect(err).To(gomega.HaveOccurred()) + }) }) }) diff --git a/work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml b/work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml index efb889f9d..3542af39e 100644 --- a/work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml +++ b/work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml @@ -187,6 +187,9 @@ spec: - path type: object type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map type: description: |- Type defines the option of how status can be returned. diff --git a/work/v1/types.go b/work/v1/types.go index 0a66a837d..08f560fd9 100644 --- a/work/v1/types.go +++ b/work/v1/types.go @@ -226,6 +226,8 @@ type FeedbackRule struct { Type FeedBackType `json:"type"` // JsonPaths defines the json path under status field to be synced. + // +listType:=map + // +listMapKey:=name // +optional JsonPaths []JsonPath `json:"jsonPaths,omitempty"` } diff --git a/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml b/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml index 6acb6340f..499146f25 100644 --- a/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml +++ b/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml @@ -210,6 +210,9 @@ spec: - path type: object type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map type: description: |- Type defines the option of how status can be returned.