From bc52533ceb990a1e1720fde9fa478cdf554745b0 Mon Sep 17 00:00:00 2001 From: Sebastian Widmer Date: Wed, 24 Nov 2021 13:43:06 +0100 Subject: [PATCH] Allow deleting disappeared groups (#13) * Allow passing additional parameters to GroupSync * Update underlying version to `v0.2.0` * Document new parameter `deleteDisappearedGroups` * Remove annotation no longer required --- class/defaults.yml | 2 +- component/config.jsonnet | 6 +---- .../ROOT/pages/references/parameters.adoc | 19 ++++++++------- tests/defaults.yml | 1 + .../redhatcop.redhat.io_groupsyncs.yaml | 24 +++++++++++++++++++ .../group-sync-operator/02_groupsync.yaml | 5 +--- ...loyment_group-sync-controller-manager.yaml | 2 +- .../redhatcop.redhat.io_groupsyncs.yaml | 24 +++++++++++++++++++ ...loyment_group-sync-controller-manager.yaml | 2 +- 9 files changed, 64 insertions(+), 21 deletions(-) diff --git a/class/defaults.yml b/class/defaults.yml index e42f5cf..464aa99 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -6,7 +6,7 @@ parameters: operator: registry: quay.io repository: appuio/group-sync-operator - tag: v0.1.0 + tag: v0.2.0 manifest_version: ${group_sync_operator:images:operator:tag} manifest_url: https://raw.githubusercontent.com/appuio/group-sync-operator/${group_sync_operator:manifest_version}/config diff --git a/component/config.jsonnet b/component/config.jsonnet index 518d02a..965ff1b 100644 --- a/component/config.jsonnet +++ b/component/config.jsonnet @@ -41,12 +41,8 @@ local groupSyncs = std.filter( name: k, namespace: params.namespace, labels+: labels, - annotations+: { - 'argocd.argoproj.io/sync-options': 'SkipDryRunOnMissingResource=true', - }, }, - spec: { - schedule: params.sync[k].schedule, + spec: params.sync[k] { providers: [ { name: p } + patchProvider(params.sync[k].providers[p]) for p in std.objectFields(params.sync[k].providers) diff --git a/docs/modules/ROOT/pages/references/parameters.adoc b/docs/modules/ROOT/pages/references/parameters.adoc index d1fa452..d4a48f2 100644 --- a/docs/modules/ROOT/pages/references/parameters.adoc +++ b/docs/modules/ROOT/pages/references/parameters.adoc @@ -14,15 +14,6 @@ The namespace in which to deploy this component. [horizontal] type:: dictionary -default:: -+ -[source,yaml] ----- -operator: - registry: quay.io - repository: redhat-cop/group-sync-operator - tag: v0.0.14 ----- Dictionary containing the container images used by this component. @@ -45,6 +36,15 @@ A crontab based schedule configuration, for when to synchronize the groups. If no schedule is provided, synchronization will only occur when the `GroupSync` object is reconciled by the platform. +== `sync[].deleteDisappearedGroups` + +[horizontal] +type:: bool +default:: false + +Controls if groups disappeared from the source should be removed. The deletion of groups is provider scoped. + + == `sync[].providers` [horizontal] @@ -92,6 +92,7 @@ parameters: scope: sub bar: schedule: '* * 2 * *' + deleteDisappearedGroups: true providers: bar-azure: azure: diff --git a/tests/defaults.yml b/tests/defaults.yml index d5932f7..d3d335c 100644 --- a/tests/defaults.yml +++ b/tests/defaults.yml @@ -23,6 +23,7 @@ parameters: scope: sub other: schedule: '* * 2 * *' + deleteDisappearedGroups: true providers: foo: azure: diff --git a/tests/golden/defaults/group-sync-operator/group-sync-operator/00_crds/redhatcop.redhat.io_groupsyncs.yaml b/tests/golden/defaults/group-sync-operator/group-sync-operator/00_crds/redhatcop.redhat.io_groupsyncs.yaml index b64c226..db6feb6 100644 --- a/tests/golden/defaults/group-sync-operator/group-sync-operator/00_crds/redhatcop.redhat.io_groupsyncs.yaml +++ b/tests/golden/defaults/group-sync-operator/group-sync-operator/00_crds/redhatcop.redhat.io_groupsyncs.yaml @@ -30,6 +30,9 @@ spec: spec: description: GroupSyncSpec defines the desired state of GroupSync properties: + deleteDisappearedGroups: + description: DeleteDisappearedGroups controls if disappeared groups should be removed. The deletion of groups is provider scoped. + type: boolean providers: description: List of Providers that can be mounted by containers belonging to the pod. items: @@ -574,6 +577,27 @@ spec: - credentialsSecret - url type: object + static: + description: Static represents the Static provider + properties: + groups: + description: Groups represents a list of groups to synchronize + items: + description: StaticProvider allow statically setting Groups + properties: + name: + description: Name represents the name of the group + type: string + users: + description: Users represents a list of users to apply to the synchronized group. + items: + type: string + type: array + required: + - name + type: object + type: array + type: object required: - name type: object diff --git a/tests/golden/defaults/group-sync-operator/group-sync-operator/02_groupsync.yaml b/tests/golden/defaults/group-sync-operator/group-sync-operator/02_groupsync.yaml index f81fa6b..d8bd4d2 100644 --- a/tests/golden/defaults/group-sync-operator/group-sync-operator/02_groupsync.yaml +++ b/tests/golden/defaults/group-sync-operator/group-sync-operator/02_groupsync.yaml @@ -1,8 +1,6 @@ apiVersion: redhatcop.redhat.io/v1alpha1 kind: GroupSync metadata: - annotations: - argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true labels: app.kubernetes.io/managed-by: commodore app.kubernetes.io/name: group-sync-operator @@ -35,8 +33,6 @@ spec: apiVersion: redhatcop.redhat.io/v1alpha1 kind: GroupSync metadata: - annotations: - argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true labels: app.kubernetes.io/managed-by: commodore app.kubernetes.io/name: group-sync-operator @@ -44,6 +40,7 @@ metadata: name: other namespace: syn-group-sync-operator spec: + deleteDisappearedGroups: true providers: - azure: credentialsSecret: diff --git a/tests/golden/defaults/group-sync-operator/group-sync-operator/20_deployment_group-sync-controller-manager.yaml b/tests/golden/defaults/group-sync-operator/group-sync-operator/20_deployment_group-sync-controller-manager.yaml index 143f9c5..aacb94e 100644 --- a/tests/golden/defaults/group-sync-operator/group-sync-operator/20_deployment_group-sync-controller-manager.yaml +++ b/tests/golden/defaults/group-sync-operator/group-sync-operator/20_deployment_group-sync-controller-manager.yaml @@ -27,7 +27,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: quay.io/appuio/group-sync-operator:v0.1.0 + image: quay.io/appuio/group-sync-operator:v0.2.0 livenessProbe: httpGet: path: /healthz diff --git a/tests/golden/empty/group-sync-operator/group-sync-operator/00_crds/redhatcop.redhat.io_groupsyncs.yaml b/tests/golden/empty/group-sync-operator/group-sync-operator/00_crds/redhatcop.redhat.io_groupsyncs.yaml index b64c226..db6feb6 100644 --- a/tests/golden/empty/group-sync-operator/group-sync-operator/00_crds/redhatcop.redhat.io_groupsyncs.yaml +++ b/tests/golden/empty/group-sync-operator/group-sync-operator/00_crds/redhatcop.redhat.io_groupsyncs.yaml @@ -30,6 +30,9 @@ spec: spec: description: GroupSyncSpec defines the desired state of GroupSync properties: + deleteDisappearedGroups: + description: DeleteDisappearedGroups controls if disappeared groups should be removed. The deletion of groups is provider scoped. + type: boolean providers: description: List of Providers that can be mounted by containers belonging to the pod. items: @@ -574,6 +577,27 @@ spec: - credentialsSecret - url type: object + static: + description: Static represents the Static provider + properties: + groups: + description: Groups represents a list of groups to synchronize + items: + description: StaticProvider allow statically setting Groups + properties: + name: + description: Name represents the name of the group + type: string + users: + description: Users represents a list of users to apply to the synchronized group. + items: + type: string + type: array + required: + - name + type: object + type: array + type: object required: - name type: object diff --git a/tests/golden/empty/group-sync-operator/group-sync-operator/20_deployment_group-sync-controller-manager.yaml b/tests/golden/empty/group-sync-operator/group-sync-operator/20_deployment_group-sync-controller-manager.yaml index 143f9c5..aacb94e 100644 --- a/tests/golden/empty/group-sync-operator/group-sync-operator/20_deployment_group-sync-controller-manager.yaml +++ b/tests/golden/empty/group-sync-operator/group-sync-operator/20_deployment_group-sync-controller-manager.yaml @@ -27,7 +27,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: quay.io/appuio/group-sync-operator:v0.1.0 + image: quay.io/appuio/group-sync-operator:v0.2.0 livenessProbe: httpGet: path: /healthz