Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/v1alpha1/argocd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ type ArgoCDNotifications struct {
// Enabled defines whether argocd-notifications controller should be deployed or not
Enabled bool `json:"enabled"`

// SourceNamespaces is a list of namespaces from which the notifications controller will watch for ArgoCD Application resources.
SourceNamespaces []string `json:"sourceNamespaces,omitempty"`

// Env let you specify environment variables for Notifications pods
Env []corev1.EnvVar `json:"env,omitempty"`

Expand Down
11 changes: 11 additions & 0 deletions api/v1alpha1/argocd_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,14 @@ func Test_ParseResourceTrackingMethod(t *testing.T) {
assert.Equal(t, tt.rtm, ParseResourceTrackingMethod(tt.str))
}
}

func Test_ArgoCDNotifications_SourceNamespaces(t *testing.T) {
notifications := ArgoCDNotifications{
SourceNamespaces: []string{"ns1", "ns2"},
}
assert.Equal(t, []string{"ns1", "ns2"}, notifications.SourceNamespaces)

// Test omitempty (zero value)
emptyNotifications := ArgoCDNotifications{}
assert.Nil(t, emptyNotifications.SourceNamespaces)
}
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/v1beta1/argocd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ type ArgoCDNotifications struct {
// Enabled defines whether argocd-notifications controller should be deployed or not
Enabled bool `json:"enabled"`

// SourceNamespaces is a list of namespaces from which the notifications controller will watch for ArgoCD Notification resources.
SourceNamespaces []string `json:"sourceNamespaces,omitempty"`

// Env let you specify environment variables for Notifications pods
Env []corev1.EnvVar `json:"env,omitempty"`

Expand Down
11 changes: 11 additions & 0 deletions api/v1beta1/argocd_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,14 @@ func Test_ParseResourceTrackingMethod(t *testing.T) {
assert.Equal(t, tt.rtm, ParseResourceTrackingMethod(tt.str))
}
}

func Test_ArgoCDNotifications_SourceNamespaces(t *testing.T) {
notifications := ArgoCDNotifications{
SourceNamespaces: []string{"ns1", "ns2"},
}
assert.Equal(t, []string{"ns1", "ns2"}, notifications.SourceNamespaces)

// Test omitempty (zero value)
emptyNotifications := ArgoCDNotifications{}
assert.Nil(t, emptyNotifications.SourceNamespaces)
}
5 changes: 5 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions bundle/manifests/argoproj.io_argocds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,13 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
sourceNamespaces:
description: SourceNamespaces is a list of namespaces from which
the notifications controller will watch for ArgoCD Application
resources.
items:
type: string
type: array
version:
description: Version is the Argo CD Notifications image tag. (optional)
type: string
Expand Down Expand Up @@ -16713,6 +16720,13 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
sourceNamespaces:
description: SourceNamespaces is a list of namespaces from which
the notifications controller will watch for ArgoCD Notification
resources.
items:
type: string
type: array
version:
description: Version is the Argo CD Notifications image tag. (optional)
type: string
Expand Down
5 changes: 4 additions & 1 deletion common/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,12 @@ const (
// ArgoCDManagedByClusterArgoCDLabel is needed to identify namespace mentioned as sourceNamespace on ArgoCD
ArgoCDManagedByClusterArgoCDLabel = "argocd.argoproj.io/managed-by-cluster-argocd"

// ArgoCDManagedByClusterArgoCDLabel is needed to identify namespace mentioned as sourceNamespace on ArgoCD
// ArgoCDApplicationSetManagedByClusterArgoCDLabel is needed to identify namespace mentioned as applicationSet sourceNamespaces on ArgoCD
ArgoCDApplicationSetManagedByClusterArgoCDLabel = "argocd.argoproj.io/applicationset-managed-by-cluster-argocd"

// ArgoCDNotificationsManagedByClusterArgoCDLabel is needed to identify namespace mentioned as notifications sourceNamespaces on ArgoCD
ArgoCDNotificationsManagedByClusterArgoCDLabel = "argocd.argoproj.io/notifications-managed-by-cluster-argocd"

// ArgoCDControllerClusterRoleEnvName is an environment variable to specify a custom cluster role for Argo CD application controller
ArgoCDControllerClusterRoleEnvName = "CONTROLLER_CLUSTER_ROLE"

Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/argoproj.io_argocds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,13 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
sourceNamespaces:
description: SourceNamespaces is a list of namespaces from which
the notifications controller will watch for ArgoCD Application
resources.
items:
type: string
type: array
version:
description: Version is the Argo CD Notifications image tag. (optional)
type: string
Expand Down Expand Up @@ -16702,6 +16709,13 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
sourceNamespaces:
description: SourceNamespaces is a list of namespaces from which
the notifications controller will watch for ArgoCD Notification
resources.
items:
type: string
type: array
version:
description: Version is the Argo CD Notifications image tag. (optional)
type: string
Expand Down
11 changes: 10 additions & 1 deletion controllers/argocd/argocd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ type ReconcileArgoCD struct {
ManagedSourceNamespaces map[string]string
// Stores a list of ApplicationSetSourceNamespaces as keys
ManagedApplicationSetSourceNamespaces map[string]string

// Stores a list of NotificationsSourceNamespaces as keys
ManagedNotificationsSourceNamespaces map[string]string

// Stores label selector used to reconcile a subset of ArgoCD
LabelSelector string

Expand Down Expand Up @@ -255,6 +259,9 @@ func (r *ReconcileArgoCD) internalReconcile(ctx context.Context, request ctrl.Re
if err := r.removeUnmanagedApplicationSetSourceNamespaceResources(argocd); err != nil {
return reconcile.Result{}, argocd, argoCDStatus, fmt.Errorf("failed to remove resources from applicationSetSourceNamespaces, error: %w", err)
}
if err := r.removeUnmanagedNotificationsSourceNamespaceResources(argocd); err != nil {
return reconcile.Result{}, argocd, argoCDStatus, fmt.Errorf("failed to remove resources from notificationsSourceNamespaces, error: %w", err)
}

if err := r.removeDeletionFinalizer(argocd); err != nil {
return reconcile.Result{}, argocd, argoCDStatus, err
Expand Down Expand Up @@ -285,7 +292,9 @@ func (r *ReconcileArgoCD) internalReconcile(ctx context.Context, request ctrl.Re
if err = r.setManagedApplicationSetSourceNamespaces(argocd); err != nil {
return reconcile.Result{}, argocd, argoCDStatus, err
}

if err = r.setManagedNotificationsSourceNamespaces(argocd); err != nil {
return reconcile.Result{}, argocd, argoCDStatus, err
}
// Handle NamespaceManagement reconciliation and check if Namespace Management is enabled via the Subscription env variable.
if isNamespaceManagementEnabled() {
if err := r.reconcileNamespaceManagement(argocd); err != nil {
Expand Down
Loading