Skip to content

Commit 3a79048

Browse files
authored
Implement Pruning of removed upstream groups (#166)
* wip: looking into pruning * wip: actually prune based on syncTime annotation * change how syncStartTime is used so each group still gets it's own sync time annotation like currently. other minor cleanup * refactoring names * Return prune value * Add missing prune to CRD for AzureProvider * Update documentation * Remove debugging info from logger on prune * Prune groups and include count of pruned groups in sync complete status log * Add new metric for groupsPruned * Restore accidental removal in deepcopy * Add backticks in docs around prune false
1 parent 0dc4c34 commit 3a79048

File tree

13 files changed

+169
-10
lines changed

13 files changed

+169
-10
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Groups contained within Azure Active Directory can be synchronized into OpenShif
7777
| `filter` | Graph API filter | | No |
7878
| `groups` | List of groups to filter against | | No |
7979
| `userNameAttributes` | Fields on a user record to use as the User Name | `userPrincipalName` | No |
80+
| `prune` | Prune Whether to prune groups that are no longer in Azure | `false` | No |
8081

8182
The following is an example of a minimal configuration that can be applied to integrate with a Azure provider:
8283

@@ -131,6 +132,7 @@ Teams stored within a GitHub organization can be synchronized into OpenShift. Th
131132
| `organization` | Organization to synchronize against | | Yes |
132133
| `teams` | List of teams to filter against | | No |
133134
| `url` | Base URL for the GitHub or GitHub Enterprise host (Must contain a trailing slash) | | No |
135+
| `prune` | Prune Whether to prune groups that are no longer in GitHub | `false` | No |
134136

135137
The following is an example of a minimal configuration that can be applied to integrate with a GitHub provider:
136138

@@ -199,9 +201,10 @@ Groups stored within a GitLab can be synchronized into OpenShift. The following
199201
| `ca` | Reference to a resource containing a SSL certificate to use for communication (See below) | | No |
200202
| `caSecret` | **DEPRECATED** Reference to a secret containing a SSL certificate to use for communication (See below) | | No |
201203
| `credentialsSecret` | Reference to a secret containing authentication details (See below) | | Yes |
202-
| `insecure` | Ignore SSL verification | 'false' | No |
204+
| `insecure` | Ignore SSL verification | `false` | No |
203205
| `groups` | List of groups to filter against | | No |
204206
| `url` | Base URL for the GitLab instance | `https://gitlab.com` | No |
207+
| `prune` | Prune Whether to prune groups that are no longer in GitLab | `false` | No |
205208

206209
The following is an example of a minimal configuration that can be applied to integrate with a GitHub provider:
207210

@@ -255,14 +258,15 @@ The configurations of the three primary schemas (`rfc2307`, `activeDirectory` an
255258
| `ca` | Reference to a resource containing a SSL certificate to use for communication (See below) | | No |
256259
| `caSecret` | **DEPRECATED** Reference to a secret containing a SSL certificate to use for communication (See below) | | No |
257260
| `credentialsSecret` | Reference to a secret containing authentication details (See below) | | No |
258-
| `insecure` | Ignore SSL verification | 'false' | No |
261+
| `insecure` | Ignore SSL verification | `false` | No |
259262
| `groupUIDNameMapping` | User defined name mapping | | No |
260263
| `rfc2307` | Configuration using the [rfc2307](https://docs.openshift.com/container-platform/latest/authentication/ldap-syncing.html#ldap-syncing-rfc2307_ldap-syncing-groups) schema | | No |
261264
| `activeDirectory` | Configuration using the [activeDirectory](https://docs.openshift.com/container-platform/4.5/authentication/ldap-syncing.html#ldap-syncing-activedir_ldap-syncing-groups) schema | | No |
262265
| `augmentedActiveDirectory` | Configuration using the [activeDirectory](https://docs.openshift.com/container-platform/4.5/authentication/ldap-syncing.html#ldap-syncing-augmented-activedir_ldap-syncing-groups) schema | | No |
263266
| `url` | Connection URL for the LDAP server | `https://gitlab.cldap://ldapserver:389om` | No |
264267
| `whitelist` | Explicit list of groups to synchronize | | No |
265268
| `blacklist` | Explicit list of groups to not synchronize | | No |
269+
| `prune` | Prune Whether to prune groups that are no longer in LDAP | `false` | No |
266270

267271
The following is an example using the `rfc2307` schema:
268272

@@ -361,11 +365,12 @@ Groups stored within Keycloak can be synchronized into OpenShift. The following
361365
| `caSecret` | **DEPRECATED** Reference to a secret containing a SSL certificate to use for communication (See below) | | No |
362366
| `credentialsSecret` | Reference to a secret containing authentication details (See below) | | Yes |
363367
| `groups` | List of groups to filter against | | No |
364-
| `insecure` | Ignore SSL verification | 'false' | No |
368+
| `insecure` | Ignore SSL verification | `false` | No |
365369
| `loginRealm` | Realm to authenticate against | `master` | No |
366370
| `realm` | Realm to synchronize | | Yes |
367371
| `scope` | Scope for group synchronization. Options are `one` for one level or `sub` to include subgroups | `sub` | No |
368372
| `url` | URL Location for Keycloak | | Yes |
373+
| `prune` | Prune Whether to prune groups that are no longer in Keycloak | `false` | No |
369374

370375
The following is an example of a minimal configuration that can be applied to integrate with a Keycloak provider:
371376

@@ -417,7 +422,7 @@ The following table describes the set of configuration options for the Okta prov
417422
| `extractLoginUsername` | Bool to determine if you should extract username from okta login | `false` | No |
418423
| `profileKey` | Attribute field on Okta User Profile you would like to use as identity | `'login'` | No |
419424
| `groupLimit` | Integer to set the maximum number of groups to retrieve from OKTA per request. | `1000` | No |
420-
425+
| `prune` | Prune Whether to prune groups that are no longer in OKTA | `false` | No |
421426

422427
The following is an example of a minimal configuration that can be applied to integrate with an Okta provider:
423428

api/v1alpha1/groupsync_types.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ type KeycloakProvider struct {
185185
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Keycloak URL",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
186186
// +kubebuilder:validation:Required
187187
URL string `json:"url"`
188+
189+
// Prune Whether to prune groups that are no longer in Keycloak. Default is false
190+
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Prune",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
191+
// +kubebuilder:validation:Optional
192+
Prune bool `json:"prune"`
188193
}
189194

190195
// GitHubProvider represents integration with GitHub
@@ -238,6 +243,11 @@ type GitHubProvider struct {
238243
// +kubebuilder:validation:Optional
239244
// +kubebuilder:default="https://api.github.com/graphql"
240245
V4URL *string `json:"v4url,omitempty"`
246+
247+
// Prune Whether to prune groups that are no longer in GitHub. Default is false
248+
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Prune",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
249+
// +kubebuilder:validation:Optional
250+
Prune bool `json:"prune"`
241251
}
242252

243253
// GitLabProvider represents integration with GitLab
@@ -274,6 +284,11 @@ type GitLabProvider struct {
274284
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="GitLab URL",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
275285
// +kubebuilder:validation:Optional
276286
URL *string `json:"url,omitempty"`
287+
288+
// Prune Whether to prune groups that are no longer in GitLab. Default is false
289+
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Prune",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
290+
// +kubebuilder:validation:Optional
291+
Prune bool `json:"prune"`
277292
}
278293

279294
// LdapProvider represents integration with an LDAP server
@@ -335,6 +350,11 @@ type LdapProvider struct {
335350
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Blacklisted groups to not synchronize",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
336351
// +kubebuilder:validation:Optional
337352
Blacklist *[]string `json:"blacklist,omitempty"`
353+
354+
// Prune Whether to prune groups that are no longer in LDAP. Default is false
355+
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Prune",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
356+
// +kubebuilder:validation:Optional
357+
Prune bool `json:"prune"`
338358
}
339359

340360
// AzureProvider represents integration with Azure
@@ -374,6 +394,11 @@ type AzureProvider struct {
374394
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Azure UserName Attributes",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
375395
// +kubebuilder:validation:Optional
376396
UserNameAttributes *[]string `json:"userNameAttributes,omitempty"`
397+
398+
// Prune Whether to prune groups that are no longer in Azure. Default is false
399+
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Prune",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
400+
// +kubebuilder:validation:Optional
401+
Prune bool `json:"prune"`
377402
}
378403

379404
// OktaProvider represents integration with Okta
@@ -407,6 +432,11 @@ type OktaProvider struct {
407432
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Group Limit",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number"}
408433
// +kubebuilder:validation:Optional
409434
GroupLimit int `json:"groupLimit"`
435+
436+
// Prune Whether to prune groups that are no longer in OKTA. Default is false
437+
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Prune",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
438+
// +kubebuilder:validation:Optional
439+
Prune bool `json:"prune"`
410440
}
411441

412442
// ObjectRef represents a reference to an item within a Secret

config/crd/bases/redhatcop.redhat.io_groupsyncs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ spec:
7777
insecure:
7878
description: Insecure specifies whether to allow for unverified certificates to be used when communicating to Azure
7979
type: boolean
80+
prune:
81+
description: Prune Whether to prune groups that are no longer in Azure. Default is false
82+
type: boolean
8083
url:
8184
description: URL is the location of the Azure platform
8285
type: string
@@ -169,6 +172,9 @@ spec:
169172
organization:
170173
description: Organization represents the location to source teams to synchronize
171174
type: string
175+
prune:
176+
description: Prune Whether to prune groups that are no longer in GitHub. Default is false
177+
type: boolean
172178
teams:
173179
description: Teams represents a filtered list of teams to synchronize
174180
items:
@@ -265,6 +271,9 @@ spec:
265271
insecure:
266272
description: Insecure specifies whether to allow for unverified certificates to be used when communicating to GitLab
267273
type: boolean
274+
prune:
275+
description: Prune Whether to prune groups that are no longer in GitLab. Default is false
276+
type: boolean
268277
url:
269278
description: URL is the location of the GitLab server
270279
type: string
@@ -354,6 +363,9 @@ spec:
354363
loginRealm:
355364
description: LoginRealm is the Keycloak realm to authenticate against
356365
type: string
366+
prune:
367+
description: Prune Whether to prune groups that are no longer in Keycloak. Default is false
368+
type: boolean
357369
realm:
358370
description: Realm is the realm containing the groups to synchronize against
359371
type: string
@@ -575,6 +587,9 @@ spec:
575587
insecure:
576588
description: Insecure specifies whether to allow for unverified certificates to be used when communicating to LDAP
577589
type: boolean
590+
prune:
591+
description: Prune Whether to prune groups that are no longer in LDAP. Default is false
592+
type: boolean
578593
rfc2307:
579594
description: RFC2307Config represents the configuration for a RFC2307 schema
580595
properties:
@@ -719,6 +734,9 @@ spec:
719734
profileKey:
720735
description: ProfileKey the attribute from Okta you would like to use as the user identifier. Default is "login"
721736
type: string
737+
prune:
738+
description: Prune Whether to prune groups that are no longer in OKTA. Default is false
739+
type: boolean
722740
url:
723741
description: URL is the location of the Okta domain server
724742
type: string

0 commit comments

Comments
 (0)