Skip to content

Commit a9d7912

Browse files
committed
downstream the support for custom labels for configmap and secret created by argo-rollout
Signed-off-by: Alka Kumari <[email protected]>
1 parent 35d543b commit a9d7912

File tree

4 files changed

+106
-3
lines changed

4 files changed

+106
-3
lines changed

cmd/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,16 @@ func main() {
246246
setupLog.Info("Argo Rollouts manager running in cluster-scoped mode")
247247
}
248248

249+
resourceLabels := map[string]string{
250+
argocdcommon.ArgoCDTrackedByOperatorLabel: argocdcommon.ArgoCDAppName,
251+
}
252+
249253
if err = (&rolloutManagerProvisioner.RolloutManagerReconciler{
250254
Client: mgr.GetClient(),
251255
Scheme: mgr.GetScheme(),
252256
OpenShiftRoutePluginLocation: getArgoRolloutsOpenshiftRouteTrafficManagerPath(),
253257
NamespaceScopedArgoRolloutsController: isNamespaceScoped,
258+
ResourceLabels: resourceLabels,
254259
}).SetupWithManager(mgr); err != nil {
255260
setupLog.Error(err, "unable to create controller", "controller", "Argo Rollouts")
256261
os.Exit(1)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/redhat-developer/gitops-operator
33
go 1.24.6
44

55
require (
6-
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251029155400-4619e3168941
6+
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765
77
github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20251024105544-f7c3f5b0cc95
88
github.com/argoproj/argo-cd/v3 v3.1.8
99
github.com/argoproj/gitops-engine v0.7.1-0.20250905160054-e48120133eec

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ github.com/alicebob/miniredis/v2 v2.35.0 h1:QwLphYqCEAo1eu1TqPRN2jgVMPBweeQcR21j
2929
github.com/alicebob/miniredis/v2 v2.35.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM=
3030
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
3131
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
32-
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251029155400-4619e3168941 h1:uqkUVemiOX050ktlgbyYs4jef38HRU17C9sTzHTL9JU=
33-
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251029155400-4619e3168941/go.mod h1:WPyZkNHZjir/OTt8mrRwcUZKe1euHrHPJsRv1Wp/F/0=
32+
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765 h1:zVN+W/nQrRB/kB63YcvcCseuiE//sEzNw6Oa8rqiFOs=
33+
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765/go.mod h1:WPyZkNHZjir/OTt8mrRwcUZKe1euHrHPJsRv1Wp/F/0=
3434
github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20251024105544-f7c3f5b0cc95 h1:v2J4IPd8Fab5udUD7nMZsYflqGDhkVGx30q5uenMBbE=
3535
github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20251024105544-f7c3f5b0cc95/go.mod h1:LTBNqNbKk9Us5xiCrK612HLOr8SJFfyxlMJQErzMghg=
3636
github.com/argoproj/argo-cd/v3 v3.1.8 h1:NkLPiRI5qGkV+q1EN3O7/0Wb9O/MVl62vadKteZqMUw=
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package parallel
18+
19+
import (
20+
"context"
21+
22+
rolloutmanagerv1alpha1 "github.com/argoproj-labs/argo-rollouts-manager/api/v1alpha1"
23+
. "github.com/onsi/ginkgo/v2"
24+
. "github.com/onsi/gomega"
25+
"github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture"
26+
k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s"
27+
fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils"
28+
appsv1 "k8s.io/api/apps/v1"
29+
corev1 "k8s.io/api/core/v1"
30+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31+
"sigs.k8s.io/controller-runtime/pkg/client"
32+
)
33+
34+
var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
35+
36+
Context("1-121_validate_custom_labels_rollouts", func() {
37+
38+
var (
39+
k8sClient client.Client
40+
ctx context.Context
41+
)
42+
43+
BeforeEach(func() {
44+
fixture.EnsureParallelCleanSlate()
45+
k8sClient, _ = fixtureUtils.GetE2ETestKubeClient()
46+
ctx = context.Background()
47+
})
48+
49+
It("ensures that custom labels set by the operator are added to Argo Rollouts resources", func() {
50+
51+
By("creating namespace-scoped RolloutManager instance")
52+
rolloutManager := &rolloutmanagerv1alpha1.RolloutManager{
53+
ObjectMeta: metav1.ObjectMeta{
54+
Name: "test-rollout-manager",
55+
Namespace: "openshift-gitops",
56+
},
57+
}
58+
Expect(k8sClient.Create(ctx, rolloutManager)).To(Succeed())
59+
60+
By("waiting for Argo Rollouts deployment to be created and become available")
61+
depl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts", Namespace: "openshift-gitops"}}
62+
Eventually(depl, "2m", "2s").Should(k8sFixture.ExistByName())
63+
64+
By("verifying Argo Rollouts Secret has the custom labels")
65+
labelKey := "operator.argoproj.io/tracked-by"
66+
labelValue := "argocd"
67+
secret := &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts-notification-secret", Namespace: "openshift-gitops"}}
68+
Eventually(secret, "2m", "1s").Should(k8sFixture.ExistByName())
69+
Expect(secret.Labels).Should(HaveKeyWithValue(labelKey, labelValue))
70+
71+
By("verifying Argo Rollouts ConfigMap has the custom labels")
72+
configMap := &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts-config", Namespace: "openshift-gitops"}}
73+
Eventually(configMap, "2m", "1s").Should(k8sFixture.ExistByName())
74+
Expect(configMap.Labels).Should(HaveKeyWithValue(labelKey, labelValue))
75+
76+
By("updating RolloutManager spec")
77+
78+
// Add a new label to trigger reconciliation
79+
if rolloutManager.ObjectMeta.Labels == nil {
80+
rolloutManager.ObjectMeta.Labels = make(map[string]string)
81+
}
82+
rolloutManager.ObjectMeta.Labels["test-update"] = "true"
83+
patch := client.MergeFrom(rolloutManager.DeepCopy())
84+
Expect(k8sClient.Patch(ctx, rolloutManager, patch)).To(Succeed())
85+
86+
By("ensures that custom labels persist in configmap after RolloutManager updates")
87+
configMap = &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts-config", Namespace: "openshift-gitops"}}
88+
Eventually(configMap, "2m", "1s").Should(k8sFixture.ExistByName())
89+
Expect(configMap.Labels).Should(HaveKeyWithValue(labelKey, labelValue))
90+
91+
By("ensures that custom labels persist in secret after RolloutManager updates")
92+
secret = &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts-notification-secret", Namespace: "openshift-gitops"}}
93+
Eventually(secret, "2m", "1s").Should(k8sFixture.ExistByName())
94+
Expect(secret.Labels).Should(HaveKeyWithValue(labelKey, labelValue))
95+
})
96+
97+
})
98+
})

0 commit comments

Comments
 (0)