Skip to content

Commit 9cd5c24

Browse files
authored
add generic external member provider and static member provider (#1249)
1 parent 7c518dc commit 9cd5c24

15 files changed

+404
-255
lines changed

repo-guard/README.md

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,3 @@ title: Repo Guard
33
---
44

55
Repo Guard Greenhouse Plugin manages Github teams, team memberships and repository & team assignments.
6-
7-
## Hierarchy of Custom Resources
8-
9-
![](img/overview.png)
10-
11-
## Custom Resources
12-
13-
### `Github` – an installation of Github App
14-
15-
```
16-
apiVersion: githubguard.sap/v1
17-
kind: Github
18-
metadata:
19-
name: com
20-
spec:
21-
webURL: https://github.com
22-
v3APIURL: https://api.github.com
23-
integrationID: 123456
24-
clientUserAgent: greenhouse-repo-guard
25-
secret: github-com-secret
26-
```
27-
28-
### `GithubOrganization` with Feature & Action Flags
29-
```
30-
apiVersion: githubguard.sap/v1
31-
kind: GithubOrganization
32-
metadata:
33-
name: com--greenhouse-sandbox
34-
labels:
35-
githubguard.sap/addTeam: "true"
36-
githubguard.sap/removeTeam: "true"
37-
githubguard.sap/addOrganizationOwner: "true"
38-
githubguard.sap/removeOrganizationOwner: "true"
39-
githubguard.sap/addRepositoryTeam: "true"
40-
githubguard.sap/removeRepositoryTeam: "true"
41-
githubguard.sap/dryRun: "false"
42-
```
43-
44-
Default team & repository assignments:
45-
![](img/default-team-assignment.png)
46-
47-
48-
### `GithubTeamRepository` for exception team & repository assignments
49-
![](img/github-team-repository.png)
50-
51-
52-
### `GithubAccountLink` for external account matching
53-
```
54-
apiVersion: githubguard.sap/v1
55-
kind: GithubAccountLink
56-
metadata:
57-
annotations:
58-
name: com-123456
59-
spec:
60-
userID: 123456
61-
githubID: 2042059
62-
github: com
63-
```

repo-guard/charts/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ apiVersion: v2
55
name: repo-guard
66
description: A Helm chart for Kubernetes
77
type: application
8-
version: 1.4.5
9-
appVersion: "1.4.5"
8+
version: 1.5.0
9+
appVersion: "1.5.0"
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: apiextensions.k8s.io/v1
5+
kind: CustomResourceDefinition
6+
metadata:
7+
annotations:
8+
controller-gen.kubebuilder.io/version: v0.19.0
9+
name: genericexternalmemberproviders.githubguard.sap
10+
spec:
11+
group: githubguard.sap
12+
names:
13+
kind: GenericExternalMemberProvider
14+
listKind: GenericExternalMemberProviderList
15+
plural: genericexternalmemberproviders
16+
singular: genericexternalmemberprovider
17+
scope: Namespaced
18+
versions:
19+
- name: v1
20+
schema:
21+
openAPIV3Schema:
22+
description: GenericExternalMemberProvider is the Schema for HTTP based external
23+
member providers
24+
properties:
25+
apiVersion:
26+
description: |-
27+
APIVersion defines the versioned schema of this representation of an object.
28+
Servers should convert recognized schemas to the latest internal value, and
29+
may reject unrecognized values.
30+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
31+
type: string
32+
kind:
33+
description: |-
34+
Kind is a string value representing the REST resource this object represents.
35+
Servers may infer this from the endpoint the client submits requests to.
36+
Cannot be updated.
37+
In CamelCase.
38+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
39+
type: string
40+
metadata:
41+
type: object
42+
spec:
43+
description: |-
44+
GenericExternalMemberProviderSpec contains HTTP configuration for generic providers
45+
Secret may contain username/password or token.
46+
properties:
47+
endpoint:
48+
type: string
49+
idField:
50+
type: string
51+
pageParam:
52+
type: string
53+
paginated:
54+
type: boolean
55+
resultsField:
56+
type: string
57+
secret:
58+
type: string
59+
totalPagesField:
60+
type: string
61+
testConnectionURL:
62+
type: string
63+
type: object
64+
status:
65+
properties:
66+
error:
67+
type: string
68+
state:
69+
type: string
70+
timestamp:
71+
format: date-time
72+
type: string
73+
type: object
74+
type: object
75+
served: true
76+
storage: true
77+
subresources:
78+
status: {}

repo-guard/charts/crds/githubteam-crd.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,34 @@ spec:
6666
distributionListID:
6767
type: string
6868
type: object
69+
genericHTTP:
70+
properties:
71+
group:
72+
type: string
73+
provider:
74+
type: string
75+
type: object
76+
ldap:
77+
properties:
78+
group:
79+
type: string
80+
provider:
81+
type: string
82+
type: object
6983
ldapGroup:
7084
properties:
7185
group:
7286
type: string
7387
ldapGroupProvider:
7488
type: string
7589
type: object
90+
static:
91+
properties:
92+
group:
93+
type: string
94+
provider:
95+
type: string
96+
type: object
7697
type: object
7798
github:
7899
type: string
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: apiextensions.k8s.io/v1
5+
kind: CustomResourceDefinition
6+
metadata:
7+
annotations:
8+
controller-gen.kubebuilder.io/version: v0.19.0
9+
name: staticmemberproviders.githubguard.sap
10+
spec:
11+
group: githubguard.sap
12+
names:
13+
kind: StaticMemberProvider
14+
listKind: StaticMemberProviderList
15+
plural: staticmemberproviders
16+
singular: staticmemberprovider
17+
scope: Namespaced
18+
versions:
19+
- name: v1
20+
schema:
21+
openAPIV3Schema:
22+
description: StaticMemberProvider provides static members by group
23+
properties:
24+
apiVersion:
25+
description: |-
26+
APIVersion defines the versioned schema of this representation of an object.
27+
Servers should convert recognized schemas to the latest internal value, and
28+
may reject unrecognized values.
29+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
30+
type: string
31+
kind:
32+
description: |-
33+
Kind is a string value representing the REST resource this object represents.
34+
Servers may infer this from the endpoint the client submits requests to.
35+
Cannot be updated.
36+
In CamelCase.
37+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
38+
type: string
39+
metadata:
40+
type: object
41+
spec:
42+
properties:
43+
groups:
44+
items:
45+
properties:
46+
group:
47+
type: string
48+
members:
49+
items:
50+
type: string
51+
type: array
52+
type: object
53+
type: array
54+
type: object
55+
status:
56+
properties:
57+
error:
58+
type: string
59+
state:
60+
type: string
61+
timestamp:
62+
format: date-time
63+
type: string
64+
type: object
65+
type: object
66+
served: true
67+
storage: true
68+
subresources:
69+
status: {}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and Greenhouse contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
{{- if .Values.genericExternalMemberProviders }}
5+
{{- range $idx, $gep := .Values.genericExternalMemberProviders }}
6+
apiVersion: githubguard.sap/v1
7+
kind: GenericExternalMemberProvider
8+
metadata:
9+
name: {{ $gep.name | required "genericExternalMemberProviders[].name is required" }}
10+
spec:
11+
endpoint: {{ $gep.endpoint | required "genericExternalMemberProviders[].endpoint is required" }}
12+
secret: {{ printf "%s-genericext-secret" (lower $gep.name) }}
13+
{{- if $gep.idField }}
14+
idField: {{ $gep.idField }}
15+
{{- end }}
16+
{{- if $gep.resultsField }}
17+
resultsField: {{ $gep.resultsField }}
18+
{{- end }}
19+
{{- if hasKey $gep "paginated" }}
20+
paginated: {{ $gep.paginated }}
21+
{{- end }}
22+
{{- if $gep.pageParam }}
23+
pageParam: {{ $gep.pageParam }}
24+
{{- end }}
25+
{{- if $gep.totalPagesField }}
26+
totalPagesField: {{ $gep.totalPagesField }}
27+
{{- end }}
28+
{{- if $gep.testConnectionURL }}
29+
testConnectionURL: {{ $gep.testConnectionURL }}
30+
{{- end }}
31+
---
32+
{{- if or $gep.username $gep.password }}
33+
apiVersion: v1
34+
kind: Secret
35+
metadata:
36+
name: {{ printf "%s-genericext-secret" (lower $gep.name) }}
37+
type: Opaque
38+
data:
39+
username: {{ $gep.username | default "" | b64enc }}
40+
password: {{ $gep.password | default "" | b64enc }}
41+
---
42+
{{- end }}
43+
{{- end }}
44+
{{- end }}

repo-guard/charts/templates/githubteam.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ metadata:
2020
githubguard.sap/require-osmp-check: "true"
2121
{{- end }}
2222
spec:
23-
{{- if or $team.distributionListID $team.ldapGroup }}
23+
{{- if or $team.distributionListID $team.ldapGroup $team.ldap $team.genericHTTP $team.static }}
2424
externalMemberProvider:
2525
{{- if $team.distributionListID }}
2626
distributionList:
@@ -32,6 +32,25 @@ spec:
3232
ldapGroupProvider: "{{ $.Values.ldap.name }}"
3333
group: {{ $team.ldapGroup }}
3434
{{- end }}
35+
{{- if $team.ldap }}
36+
ldap:
37+
{{- if $team.ldap.provider }}
38+
provider: {{ $team.ldap.provider }}
39+
{{- else if $.Values.ldap.name }}
40+
provider: "{{ $.Values.ldap.name }}"
41+
{{- end }}
42+
group: {{ $team.ldap.group }}
43+
{{- end }}
44+
{{- if $team.genericHTTP }}
45+
genericHTTP:
46+
provider: {{ $team.genericHTTP.provider }}
47+
group: {{ $team.genericHTTP.group }}
48+
{{- end }}
49+
{{- if $team.static }}
50+
static:
51+
provider: {{ $team.static.provider }}
52+
group: {{ $team.static.group }}
53+
{{- end }}
3554
{{- end }}
3655
github: {{ $githubKey }}
3756
organization: {{ $org.organization }}

0 commit comments

Comments
 (0)