Add feature to add default labels to all resources (#62)

Fixes #41 
Thanks to @mhartmann-jaconi for the Helm changes in #42
This commit is contained in:
M. Essam
2025-10-07 13:59:50 +03:00
committed by GitHub
parent 1b36287705
commit 4b98bf9ff9
10 changed files with 94 additions and 10 deletions
@@ -46,10 +46,11 @@ var _ = Describe("NBResource Controller", func() {
server = httptest.NewServer(mux)
netbirdClient = netbird.New(server.URL, "ABC")
controllerReconciler = &NBResourceReconciler{
Client: k8sClient,
Scheme: k8sClient.Scheme(),
netbird: netbirdClient,
ClusterName: "kubernetes",
Client: k8sClient,
Scheme: k8sClient.Scheme(),
netbird: netbirdClient,
ClusterName: "kubernetes",
DefaultLabels: map[string]string{"dog": "bark"},
}
By("creating the custom resource for the Kind NBResource")
@@ -125,6 +126,7 @@ var _ = Describe("NBResource Controller", func() {
Expect(err).NotTo(HaveOccurred())
nbGroup := &netbirdiov1.NBGroup{}
Expect(k8sClient.Get(ctx, types.NamespacedName{Namespace: "default", Name: "meow"}, nbGroup)).To(Succeed())
Expect(nbGroup.Labels).To(HaveKeyWithValue("dog", "bark"))
nbGroup.Status.GroupID = util.Ptr("test")
Expect(k8sClient.Status().Update(ctx, nbGroup)).To(Succeed())
})
@@ -453,6 +455,7 @@ var _ = Describe("NBResource Controller", func() {
nbPolicy := &netbirdiov1.NBPolicy{}
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: nbresource.Status.PolicyNameMapping[policyGenName]}, nbPolicy)).To(Succeed())
Expect(nbPolicy.Status.ManagedServiceList).To(ContainElement("default/test-resource"))
Expect(nbPolicy.Labels).To(HaveKeyWithValue("dog", "bark"))
})
When("Source groups is not defined", func() {