From 384803b01c50828e198196f33e4c6db25be8b3ac Mon Sep 17 00:00:00 2001 From: Xiangjing Li <55890329+xiangjingli@users.noreply.github.com> Date: Mon, 8 Jul 2024 21:03:27 -0400 Subject: [PATCH] add new kustomization e2e test yamls (#406) Signed-off-by: Xiangjing Li --- pkg/utils/gitrepo_test.go | 2 +- .../base/KlusterletAddonConfig.yaml | 23 ++++++++++ .../kustomizeLabels/base/ManagedCluster.yaml | 10 +++++ .../kustomizeLabels/base/Namespace.yaml | 7 ++++ .../kustomizeLabels/base/kustomization.yaml | 7 ++++ .../namctigtd27d/kustomization.yaml | 42 +++++++++++++++++++ 6 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 test/github/kustomizeLabels/base/KlusterletAddonConfig.yaml create mode 100644 test/github/kustomizeLabels/base/ManagedCluster.yaml create mode 100644 test/github/kustomizeLabels/base/Namespace.yaml create mode 100644 test/github/kustomizeLabels/base/kustomization.yaml create mode 100644 test/github/kustomizeLabels/namctigtd27d/kustomization.yaml diff --git a/pkg/utils/gitrepo_test.go b/pkg/utils/gitrepo_test.go index 29cc5933..bf802359 100644 --- a/pkg/utils/gitrepo_test.go +++ b/pkg/utils/gitrepo_test.go @@ -611,7 +611,7 @@ func TestSortResources(t *testing.T) { chartDirs, kustomizeDirs, crdsAndNamespaceFiles, rbacFiles, otherFiles, err := SortResources("../..", "../../test/github") g.Expect(err).NotTo(gomega.HaveOccurred()) g.Expect(len(chartDirs)).To(gomega.Equal(4)) - g.Expect(len(kustomizeDirs)).To(gomega.Equal(7)) + g.Expect(len(kustomizeDirs)).To(gomega.Equal(9)) g.Expect(len(crdsAndNamespaceFiles)).To(gomega.Equal(2)) g.Expect(len(rbacFiles)).To(gomega.Equal(3)) g.Expect(len(otherFiles)).To(gomega.Equal(5)) diff --git a/test/github/kustomizeLabels/base/KlusterletAddonConfig.yaml b/test/github/kustomizeLabels/base/KlusterletAddonConfig.yaml new file mode 100644 index 00000000..f51a1285 --- /dev/null +++ b/test/github/kustomizeLabels/base/KlusterletAddonConfig.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: agent.open-cluster-management.io/v1 +kind: KlusterletAddonConfig +metadata: + name: REPLACED BY KUSTOMIZE + namespace: REPLACED BY KUSTOMIZE +spec: + clusterName: REPLACED BY KUSTOMIZE + clusterNamespace: REPLACED BY KUSTOMIZE + applicationManager: + enabled: true + certPolicyController: + enabled: true + clusterLabels: + cloud: auto-detect + vendor: auto-detect + iamPolicyController: + enabled: true + policyController: + enabled: true + searchCollector: + enabled: true + version: 2.2.0 diff --git a/test/github/kustomizeLabels/base/ManagedCluster.yaml b/test/github/kustomizeLabels/base/ManagedCluster.yaml new file mode 100644 index 00000000..7a803221 --- /dev/null +++ b/test/github/kustomizeLabels/base/ManagedCluster.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: cluster.open-cluster-management.io/v1 +kind: ManagedCluster +metadata: + name: REPLACED BY KUSTOMIZE + namespace: REPLACED BY KUSTOMIZE + labels: #LABELS ADDED BY KUSTOMIZE + +spec: + hubAcceptsClient: true diff --git a/test/github/kustomizeLabels/base/Namespace.yaml b/test/github/kustomizeLabels/base/Namespace.yaml new file mode 100644 index 00000000..41a793ab --- /dev/null +++ b/test/github/kustomizeLabels/base/Namespace.yaml @@ -0,0 +1,7 @@ +--- +kind: Namespace +apiVersion: v1 +metadata: + name: REPLACED BY KUSTOMIZE + labels: + #cluster.open-cluster-management.io/managedCluster: diff --git a/test/github/kustomizeLabels/base/kustomization.yaml b/test/github/kustomizeLabels/base/kustomization.yaml new file mode 100644 index 00000000..1f0d0066 --- /dev/null +++ b/test/github/kustomizeLabels/base/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - KlusterletAddonConfig.yaml + - ManagedCluster.yaml + - Namespace.yaml diff --git a/test/github/kustomizeLabels/namctigtd27d/kustomization.yaml b/test/github/kustomizeLabels/namctigtd27d/kustomization.yaml new file mode 100644 index 00000000..a29545be --- /dev/null +++ b/test/github/kustomizeLabels/namctigtd27d/kustomization.yaml @@ -0,0 +1,42 @@ +resources: +- ../base + +patches: +- target: + kind: KlusterletAddonConfig + patch: | + - op: replace + path: /metadata/name + value: "namctigtd27d" + - op: replace + path: /metadata/namespace + value: "namctigtd27d" + - op: replace + path: /spec/clusterName + value: "namctigtd27d" + - op: replace + path: /spec/clusterNamespace + value: "namctigtd27d" +- target: + kind: ManagedCluster + patch: | + - op: replace + path: /metadata/name + value: "namctigtd27d" + - op: replace + path: /metadata/namespace + value: "namctigtd27d" + - op: add + path: /metadata/labels + value: + environment: dev + test1: test1 + test2: test2 + vault-csi-provider-enabled: true + +- target: + kind: Namespace + patch: | + - op: replace + path: /metadata/name + value: "namctigtd27d"