-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding NamespaceLabels and NamespaceAnnotations as TargetCustomization
- Loading branch information
1 parent
0ef20e4
commit eba7879
Showing
5 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
e2e/assets/single-cluster/namespaceLabels_targetCustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
kind: GitRepo | ||
apiVersion: fleet.cattle.io/v1alpha1 | ||
metadata: | ||
name: test | ||
namespace: fleet-local | ||
spec: | ||
repo: https://github.com/Tommy12789/fleet-examples-tommy | ||
branch: test | ||
paths: | ||
- namespaceLabels_targetCustomization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package singlecluster_test | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/rancher/fleet/e2e/testenv" | ||
"github.com/rancher/fleet/e2e/testenv/kubectl" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Helm deploy options", func() { | ||
var ( | ||
asset string | ||
k kubectl.Command | ||
) | ||
BeforeEach(func() { | ||
k = env.Kubectl.Namespace(env.Namespace) | ||
}) | ||
|
||
JustBeforeEach(func() { | ||
out, err := k.Apply("-f", testenv.AssetPath(asset)) | ||
Expect(err).ToNot(HaveOccurred(), out) | ||
}) | ||
|
||
AfterEach(func() { | ||
out, err := k.Delete("-f", testenv.AssetPath(asset)) | ||
Expect(err).ToNot(HaveOccurred(), out) | ||
}) | ||
|
||
Describe("namespaceLabels TargetCustomization", func() { | ||
BeforeEach(func() { | ||
asset = "single-cluster/namespaceLabels_targetCustomization.yaml" | ||
}) | ||
When("namespaceLabels set as targetCustomization ", func() { | ||
It("deploy the bundledeployment with the merged namespaceLabels", func() { | ||
Eventually(func() string { | ||
bundleDeploymentNames, _ := k.Namespace("cluster-fleet-local-local-1a3d67d0a899").Get("bundledeployments", "-o", "jsonpath={.items[*].metadata.name}") | ||
|
||
var bundleDeploymentName string | ||
for _, podName := range strings.Split(bundleDeploymentNames, " ") { | ||
if strings.HasPrefix(podName, "test-namespacelabels-targetcustomization") { | ||
bundleDeploymentName = podName | ||
break | ||
} | ||
} | ||
if bundleDeploymentName == "" { | ||
return "nil" | ||
} | ||
|
||
bundleDeploymentNamespacesLabels, _ := k.Namespace("cluster-fleet-local-local-1a3d67d0a899").Get("bundledeployments", bundleDeploymentName, "-o", "jsonpath={.spec.options.namespaceLabels}") | ||
return bundleDeploymentNamespacesLabels | ||
}).Should(Equal(`{"foo":"bar","this.is/a":"test"}`)) | ||
|
||
Eventually(func() string { | ||
bundleDeploymentNames, _ := k.Namespace("cluster-fleet-local-local-1a3d67d0a899").Get("bundledeployments", "-o", "jsonpath={.items[*].metadata.name}") | ||
|
||
var bundleDeploymentName string | ||
for _, podName := range strings.Split(bundleDeploymentNames, " ") { | ||
if strings.HasPrefix(podName, "test-namespacelabels-targetcustomization") { | ||
bundleDeploymentName = podName | ||
break | ||
} | ||
} | ||
if bundleDeploymentName == "" { | ||
return "nil" | ||
} | ||
|
||
bundleDeploymentNamespacesLabels, _ := k.Namespace("cluster-fleet-local-local-1a3d67d0a899").Get("bundledeployments", bundleDeploymentName, "-o", "jsonpath={.spec.options.namespaceAnnotations}") | ||
return bundleDeploymentNamespacesLabels | ||
}).Should(Equal(`{"foo":"bar","this.is/a":"test"}`)) | ||
|
||
}) | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
pkg/apis/fleet.cattle.io/v1alpha1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.