Skip to content

Commit ea988f8

Browse files
committed
refactor(charts): consolidate GitHub configuration keys and structure
1 parent cfd1105 commit ea988f8

7 files changed

Lines changed: 188 additions & 197 deletions

File tree

charts/repo-guard/templates/github.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and Greenhouse contributors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
{{- range $githubKey, $githubItem := .Values.githubs }}
4+
{{- range $githubItem := .Values.githubs }}
55
apiVersion: repoguard.sap/v1
66
kind: Github
77
metadata:
8-
name: {{ $githubKey | lower }}
8+
name: {{ $githubItem.name | lower }}
99
spec:
1010
webURL: {{ $githubItem.webURL | default "" }}
1111
v3APIURL: {{ $githubItem.v3APIURL | default "" }}
1212
integrationID: {{ $githubItem.integrationID | int64 }}
13-
clientUserAgent: repo-guard-{{ $githubKey | lower }}
14-
secret: github-{{ $githubKey | lower }}-secret
13+
clientUserAgent: repo-guard-{{ $githubItem.name | lower }}
14+
secret: github-{{ $githubItem.name | lower }}-secret
1515
---
1616
apiVersion: v1
1717
kind: Secret
1818
metadata:
19-
name: github-{{ $githubKey | lower }}-secret
19+
name: github-{{ $githubItem.name | lower }}-secret
2020
type: Opaque
2121
data:
2222
clientID: {{ $githubItem.clientID | b64enc }}
Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
11
# SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and Greenhouse contributors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
{{- range $githubKey, $githubItem := .Values.githubs }}
5-
{{- if $githubItem.githubAccountLinks }}
6-
{{- /* Build per-org email check configuration map for all orgs under this GitHub */ -}}
7-
{{- $emailCfgByOrg := dict -}}
8-
{{- if $githubItem.organizations -}}
9-
{{- range $oidx, $org := $githubItem.organizations -}}
10-
{{- if and $org.githubAccountLinkEmailCheck (or ($org.githubAccountLinkEmailCheck.domain) ($org.githubAccountLinkEmailCheck.enabled) ($org.githubAccountLinkEmailCheck.ttl)) -}}
11-
{{- $entry := dict -}}
12-
{{- if $org.githubAccountLinkEmailCheck.domain -}}
13-
{{- $_ := set $entry "domain" $org.githubAccountLinkEmailCheck.domain -}}
14-
{{- end -}}
15-
{{- if hasKey $org.githubAccountLinkEmailCheck "enabled" -}}
16-
{{- $_ := set $entry "enabled" ($org.githubAccountLinkEmailCheck.enabled | default false) -}}
17-
{{- else -}}
18-
{{- $_ := set $entry "enabled" false -}}
19-
{{- end -}}
20-
{{- if $org.githubAccountLinkEmailCheck.ttl -}}
21-
{{- $_ := set $entry "ttl" $org.githubAccountLinkEmailCheck.ttl -}}
22-
{{- end -}}
23-
{{- /* key by organization name */ -}}
24-
{{- $_ := set $emailCfgByOrg $org.organization $entry -}}
25-
{{- end -}}
26-
{{- end -}}
27-
{{- end -}}
28-
{{- range $uidx, $user := $githubItem.githubAccountLinks }}
4+
{{- /* Build per-github email check configuration maps */ -}}
5+
{{- $emailConfigs := dict -}}
6+
{{- range $org := .Values.githubOrganizations -}}
7+
{{- if and $org.githubAccountLinkEmailCheck (or ($org.githubAccountLinkEmailCheck.domain) ($org.githubAccountLinkEmailCheck.enabled) ($org.githubAccountLinkEmailCheck.ttl)) -}}
8+
{{- if not (hasKey $emailConfigs $org.github) -}}
9+
{{- $_ := set $emailConfigs $org.github (dict) -}}
10+
{{- end -}}
11+
{{- $ghCfg := get $emailConfigs $org.github -}}
12+
{{- $entry := dict -}}
13+
{{- if $org.githubAccountLinkEmailCheck.domain -}}
14+
{{- $_ := set $entry "domain" $org.githubAccountLinkEmailCheck.domain -}}
15+
{{- end -}}
16+
{{- if hasKey $org.githubAccountLinkEmailCheck "enabled" -}}
17+
{{- $_ := set $entry "enabled" ($org.githubAccountLinkEmailCheck.enabled | default false) -}}
18+
{{- else -}}
19+
{{- $_ := set $entry "enabled" false -}}
20+
{{- end -}}
21+
{{- if $org.githubAccountLinkEmailCheck.ttl -}}
22+
{{- $_ := set $entry "ttl" $org.githubAccountLinkEmailCheck.ttl -}}
23+
{{- end -}}
24+
{{- $_ := set $ghCfg $org.organization $entry -}}
25+
{{- end -}}
26+
{{- end -}}
27+
28+
{{- range $user := .Values.githubAccountLinks }}
2929
apiVersion: repoguard.sap/v1
3030
kind: GithubAccountLink
3131
metadata:
32-
name: {{ $githubKey | lower }}--{{ $user.userID | lower }}
33-
{{- $hasCfg := gt (len $emailCfgByOrg) 0 -}}
34-
{{- if $hasCfg }}
32+
name: {{ $user.github | lower }}--{{ $user.userID | lower }}
33+
{{- $emailCfgByOrg := index $emailConfigs $user.github -}}
34+
{{- if $emailCfgByOrg }}
3535
annotations:
3636
repoguard.sap/email-check-config: {{ toJson $emailCfgByOrg | quote }}
3737
{{- end }}
3838
spec:
39-
github: {{ $githubKey | lower }}
39+
github: {{ $user.github | lower }}
4040
githubUserID: {{ $user.githubID | int64 | quote }}
4141
userID: {{ $user.userID }}
4242
---
43-
{{- end }}
44-
{{- end }}
4543
{{- end }}

charts/repo-guard/templates/githuborganization.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and Greenhouse contributors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
{{- range $githubKey, $githubItem := .Values.githubs }}
5-
{{- if $githubItem.organizations }}
6-
{{- range $idx, $org := $githubItem.organizations }}
4+
{{- range $org := .Values.githubOrganizations }}
75
apiVersion: repoguard.sap/v1
86
kind: GithubOrganization
97
metadata:
10-
name: {{ $githubKey }}--{{ $org.organization | replace "/" "-" | lower }}
8+
name: {{ $org.github }}--{{ $org.organization | replace "/" "-" | lower }}
119
labels:
1210
repoguard.sap/addTeam: "{{ $org.addTeam | default "true" }}"
1311
repoguard.sap/removeTeam: "{{ $org.removeTeam | default "true" }}"
@@ -26,7 +24,7 @@ metadata:
2624
repoguard.sap/skipDefaultRepositoryTeams: "{{ $skipTeams }}"
2725
{{- end }}
2826
spec:
29-
github: {{ $githubKey }}
27+
github: {{ $org.github }}
3028
organization: {{ $org.organization }}
3129
{{- if and $org.defaultPublicRepositoryTeams (gt (len $org.defaultPublicRepositoryTeams) 0) }}
3230
defaultPublicRepositoryTeams:
@@ -42,6 +40,4 @@ spec:
4240
{{- end }}
4341
installationID: {{ $org.installationID | int64 }}
4442
---
45-
{{- end }}
46-
{{- end }}
4743
{{- end }}

charts/repo-guard/templates/githubteam.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and Greenhouse contributors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
{{- range $githubKey, $githubItem := .Values.githubs }}
5-
{{- if $githubItem.organizations }}
6-
{{- range $idx, $org := $githubItem.organizations }}
7-
{{- if $org.teams }}
8-
{{- range $tidx, $team := $org.teams }}
4+
{{- range $org := .Values.githubOrganizations }}
5+
{{- if $org.teams }}
6+
{{- range $tidx, $team := $org.teams }}
97
apiVersion: repoguard.sap/v1
108
kind: GithubTeam
119
metadata:
12-
name: {{ $githubKey }}--{{ $org.organization | replace "/" "-" | lower }}--{{ $team.name | replace "_" "-" | replace " " "-" | lower }}
10+
name: {{ $org.github }}--{{ $org.organization | replace "/" "-" | lower }}--{{ $team.name | replace "_" "-" | replace " " "-" | lower }}
1311
labels:
1412
repoguard.sap/addUser: "{{ $team.addUsers | default "true" }}"
1513
repoguard.sap/removeUser: "{{ $team.removeUsers | default "true" }}"
@@ -117,15 +115,13 @@ spec:
117115
group: {{ $team.static.group }}
118116
{{- end }}
119117
{{- end }}
120-
github: {{ $githubKey }}
118+
github: {{ $org.github }}
121119
organization: {{ $org.organization }}
122120
team: {{ $team.name }}
123121
{{- if $team.greenhouseTeam }}
124122
greenhouseTeam: {{ $team.greenhouseTeam }}
125123
{{- end }}
126124
---
127-
{{- end }}
128-
{{- end }}
129125
{{- end }}
130126
{{- end }}
131127
{{- end }}
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
# SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and Greenhouse contributors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
{{- range $githubKey, $githubItem := .Values.githubs }}
5-
{{- if $githubItem.organizations }}
6-
{{- range $idx, $org := $githubItem.organizations }}
7-
{{- if $org.teamRepositoryAssignments }}
8-
{{- range $ridx, $assign := $org.teamRepositoryAssignments }}
4+
{{- range $org := .Values.githubOrganizations }}
5+
{{- if $org.teamRepositoryAssignments }}
6+
{{- range $ridx, $assign := $org.teamRepositoryAssignments }}
97
apiVersion: repoguard.sap/v1
108
kind: GithubTeamRepository
119
metadata:
12-
name: {{ $githubKey }}--{{ $org.organization | replace "/" "-" | lower }}--{{ $assign.team | replace "_" "-" | replace " " "-" | lower }}--{{ $assign.permission }}
10+
name: {{ $org.github }}--{{ $org.organization | replace "/" "-" | lower }}--{{ $assign.team | replace "_" "-" | replace " " "-" | lower }}--{{ $assign.permission }}
1311
spec:
14-
github: {{ $githubKey }}
12+
github: {{ $org.github }}
1513
organization: {{ $org.organization }}
1614
team: {{ $assign.team }}
1715
repository:
1816
{{ toYaml $assign.repositories | indent 4 }}
1917
permission: {{ $assign.permission }}
2018
---
21-
{{- end }}
22-
{{- end }}
2319
{{- end }}
2420
{{- end }}
2521
{{- end }}

charts/repo-guard/values.yaml

Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
manager:
5-
enabled: true
5+
enabled: false
66
image:
77
repository: ghcr.io/cloudoperators/repo-guard
88
resources:
@@ -74,85 +74,87 @@ monitoring:
7474
# - user2
7575

7676
# githubs:
77-
# enterprise:
78-
# webURL:
79-
# v3APIURL:
80-
# integrationID:
81-
# clientID:
82-
# clientSecret:
83-
# privateKey:
84-
#
85-
# githubAccountLinks:
86-
# - userID:
87-
# githubUsername:
88-
# githubID:
89-
90-
# organizations:
91-
# - organization:
92-
# installationID:
93-
# # TTL overrides applied to this organization and all its teams
94-
# # If omitted, chart-wide defaults in .Values.ttl are used.
95-
# ttl:
96-
# failed: 24h # overrides ttl.team.failed and ttl.organization.failed where applicable
97-
# notfound: 24h # overrides ttl.team.notfound
98-
# completed: 72h # overrides ttl.team.completed and ttl.organization.completed where applicable
99-
# addTeam:
100-
# removeTeam:
101-
# addOrganizationOwner:
102-
# removeOrganizationOwner:
103-
# addRepositoryTeam:
104-
# removeRepositoryTeam:
105-
# dryRun:
106-
# disableInternalUsernames:
107-
# # GithubAccountLink email verification settings applied to all GALs
108-
# # associated with this GitHub (organization-level policy).
109-
# # When set, the Helm chart will populate a JSON annotation on each
110-
# # GithubAccountLink containing per-organization config entries:
111-
# # repoguard.sap/email-check-config: '{ "<org>": {"domain": "example.com", "enabled": true, "ttl": "1h" } }'
112-
# # The controller will write results into:
113-
# # repoguard.sap/email-check-results: '{ "<org>": {"domain":"example.com","status":"verified|not-part-of-org|no","timestamp":"..."} }'
114-
# githubAccountLinkEmailCheck:
115-
# # Domain to require for verified email, e.g., example.com
116-
# domain: ""
117-
# # Whether to actively check email verification status
118-
# enabled: false
119-
# # Optional TTL for re-checking email status
120-
# ttl: ""
121-
122-
# defaultPublicRepositoryTeams:
123-
# - team:
124-
# permission:
125-
#
126-
# defaultPrivateRepositoryTeams:
127-
# - team:
128-
# permission:
129-
#
130-
# organizationOwnerTeams:
131-
# -
77+
# - name: enterprise
78+
# webURL:
79+
# v3APIURL:
80+
# integrationID:
81+
# clientID:
82+
# clientSecret:
83+
# privateKey:
13284

133-
# teams:
134-
# - name:
135-
# greenhouseTeam:
136-
# # ldap group example referencing top-level ldap provider name:
137-
# # ldapGroup: cn=my-group,ou=groups,dc=example,dc=org
138-
# # ldap object example allowing provider and kind override:
139-
# # ldap:
140-
# # provider: corp-ldap # defaults to .Values.ldaps[0].name if omitted
141-
# # kind: ClusterLDAPGroupProvider # optional, auto-populated if provider matches an entry in .Values.ldaps
142-
# # group: cn=my-group,ou=groups,dc=example,dc=org
143-
# # generic http example:
144-
# # genericHTTP:
145-
# # provider: my-http-provider # must match an entry in genericExternalMemberProviders.name
146-
# # kind: ClusterGenericExternalMemberProvider # optional, auto-populated if provider matches an entry in .Values.genericExternalMemberProviders
147-
# # group: engineers
148-
# # static example:
149-
# # static:
150-
# # provider: my-static-provider # must match an entry in staticMemberProviders.name
151-
# # kind: ClusterStaticMemberProvider # optional, auto-populated if provider matches an entry in .Values.staticMemberProviders
152-
# # group: team-a
85+
# githubAccountLinks:
86+
# - github: enterprise
87+
# userID:
88+
# githubUsername:
89+
# githubID:
15390

154-
# teamRepositoryAssignments:
155-
# - team:
156-
# repositories:
157-
# -
158-
# permission:
91+
# githubOrganizations:
92+
# - github: enterprise
93+
# organization:
94+
# installationID:
95+
# # TTL overrides applied to this organization and all its teams
96+
# # If omitted, chart-wide defaults in .Values.ttl are used.
97+
# ttl:
98+
# failed: 24h # overrides ttl.team.failed and ttl.organization.failed where applicable
99+
# notfound: 24h # overrides ttl.team.notfound
100+
# completed: 72h # overrides ttl.team.completed and ttl.organization.completed where applicable
101+
# addTeam:
102+
# removeTeam:
103+
# addOrganizationOwner:
104+
# removeOrganizationOwner:
105+
# addRepositoryTeam:
106+
# removeRepositoryTeam:
107+
# dryRun:
108+
# disableInternalUsernames:
109+
# # GithubAccountLink email verification settings applied to all GALs
110+
# # associated with this GitHub (organization-level policy).
111+
# # When set, the Helm chart will populate a JSON annotation on each
112+
# # GithubAccountLink containing per-organization config entries:
113+
# # repoguard.sap/email-check-config: '{ "<org>": {"domain": "example.com", "enabled": true, "ttl": "1h" } }'
114+
# # The controller will write results into:
115+
# # repoguard.sap/email-check-results: '{ "<org>": {"domain":"example.com","status":"verified|not-part-of-org|no","timestamp":"..."} }'
116+
# githubAccountLinkEmailCheck:
117+
# # Domain to require for verified email, e.g., example.com
118+
# domain: ""
119+
# # Whether to actively check email verification status
120+
# enabled: false
121+
# # Optional TTL for re-checking email status
122+
# ttl: ""
123+
#
124+
# defaultPublicRepositoryTeams:
125+
# - team:
126+
# permission:
127+
#
128+
# defaultPrivateRepositoryTeams:
129+
# - team:
130+
# permission:
131+
#
132+
# organizationOwnerTeams:
133+
# -
134+
#
135+
# teams:
136+
# - name:
137+
# greenhouseTeam:
138+
# # ldap group example referencing top-level ldap provider name:
139+
# # ldapGroup: cn=my-group,ou=groups,dc=example,dc=org
140+
# # ldap object example allowing provider and kind override:
141+
# # ldap:
142+
# # provider: corp-ldap # defaults to .Values.ldaps[0].name if omitted
143+
# # kind: ClusterLDAPGroupProvider # optional, auto-populated if provider matches an entry in .Values.ldaps
144+
# # group: cn=my-group,ou=groups,dc=example,dc=org
145+
# # generic http example:
146+
# # genericHTTP:
147+
# # provider: my-http-provider # must match an entry in genericExternalMemberProviders.name
148+
# # kind: ClusterGenericExternalMemberProvider # optional, auto-populated if provider matches an entry in .Values.genericExternalMemberProviders
149+
# # group: engineers
150+
# # static example:
151+
# # static:
152+
# # provider: my-static-provider # must match an entry in staticMemberProviders.name
153+
# # kind: ClusterStaticMemberProvider # optional, auto-populated if provider matches an entry in .Values.staticMemberProviders
154+
# # group: team-a
155+
#
156+
# teamRepositoryAssignments:
157+
# - team:
158+
# repositories:
159+
# -
160+
# permission:

0 commit comments

Comments
 (0)