Skip to content

Commit b22f5be

Browse files
committed
feat(chart): options to keep CRDs and set custom controller environment variables
1 parent 8cc5b0d commit b22f5be

File tree

9 files changed

+58
-30
lines changed

9 files changed

+58
-30
lines changed

api/v1/managed_secret.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ type secretOwner interface {
99
}
1010

1111
type ManagedSecret struct {
12-
Namespace string `json:"namespace"`
13-
Name string `json:"name"`
1412
BasicAuth bool `json:"basicAuth"`
13+
Namespace string `json:"namespace,omitempty"`
14+
Name string `json:"name,omitempty"`
1515
}
1616

1717
func (m ManagedSecret) IsUnset() bool {

config/crd/bases/github.as-code.io_clustertokens.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,6 @@ spec:
373373
type: string
374374
required:
375375
- basicAuth
376-
- name
377-
- namespace
378376
type: object
379377
type: object
380378
type: object

config/crd/bases/github.as-code.io_tokens.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ spec:
368368
type: string
369369
required:
370370
- basicAuth
371-
- name
372-
- namespace
373371
type: object
374372
type: object
375373
type: object

deploy/charts/github-token-manager/templates/config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: v1
44
kind: Secret
55
metadata:
66
name: gtm-config
7-
{{- with .Values.commonAnnotations | default dict }}
7+
{{- with (default dict .Values.commonAnnotations) }}
88
annotations:
99
{{- range $key, $value := . }}
1010
{{ $key }}: {{ $value | quote }}
@@ -18,5 +18,11 @@ stringData:
1818
app_id: {{ .Values.config.app_id | int }}
1919
installation_id: {{ .Values.config.installation_id | int }}
2020
provider: "{{ .Values.config.provider }}"
21+
{{- if ne .Values.config.provider "file" }}
2122
key: "{{ .Values.config.key }}"
23+
{{- else }}
24+
key: /config/private.key
25+
private.key: |
26+
{{- .Values.config.key | nindent 4 }}
27+
{{- end }}
2228
{{- end }}

deploy/charts/github-token-manager/templates/crds.yaml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
44
kind: CustomResourceDefinition
55
metadata:
66
name: clustertokens.github.as-code.io
7-
{{- with .Values.commonAnnotations | default dict }}
7+
{{- with mergeOverwrite (default dict .Values.commonAnnotations) (ternary (dict "helm.sh/resource-policy" "keep") (dict) .Values.crds.keep) }}
88
annotations:
99
{{- range $key, $value := . }}
1010
{{ $key }}: {{ $value | quote }}
@@ -268,11 +268,23 @@ spec:
268268
type: array
269269
secret:
270270
properties:
271+
annotations:
272+
additionalProperties:
273+
type: string
274+
description:
275+
Extra annotations for the Secret managed by this
276+
Token
277+
type: object
271278
basicAuth:
272279
description:
273280
Create a secret with 'username' and 'password' fields
274281
for HTTP Basic Auth rather than simply 'token'
275282
type: boolean
283+
labels:
284+
additionalProperties:
285+
type: string
286+
description: Extra labels for the Secret managed by this Token
287+
type: object
276288
name:
277289
description:
278290
Name for the Secret managed by this ClusterToken
@@ -369,8 +381,6 @@ spec:
369381
type: string
370382
required:
371383
- basicAuth
372-
- name
373-
- namespace
374384
type: object
375385
type: object
376386
type: object
@@ -383,7 +393,7 @@ apiVersion: apiextensions.k8s.io/v1
383393
kind: CustomResourceDefinition
384394
metadata:
385395
name: tokens.github.as-code.io
386-
{{- with .Values.commonAnnotations | default dict }}
396+
{{- with mergeOverwrite (default dict .Values.commonAnnotations) (ternary (dict "helm.sh/resource-policy" "keep") (dict) .Values.crds.keep) }}
387397
annotations:
388398
{{- range $key, $value := . }}
389399
{{ $key }}: {{ $value | quote }}
@@ -648,15 +658,27 @@ spec:
648658
secret:
649659
description: Override the default token secret name and type
650660
properties:
661+
annotations:
662+
additionalProperties:
663+
type: string
664+
description:
665+
Extra annotations for the Secret managed by this
666+
Token
667+
type: object
651668
basicAuth:
652669
description:
653670
Create a secret with 'username' and 'password' fields
654671
for HTTP Basic Auth rather than simply 'token'
655672
type: boolean
673+
labels:
674+
additionalProperties:
675+
type: string
676+
description: Extra labels for the Secret managed by this Token
677+
type: object
656678
name:
657679
description:
658-
Name for the Secret managed by this ClusterToken
659-
(defaults to the name of the Token)
680+
Name for the Secret managed by this Token (defaults
681+
to the name of the Token)
660682
maxLength: 253
661683
type: string
662684
type: object
@@ -743,8 +765,6 @@ spec:
743765
type: string
744766
required:
745767
- basicAuth
746-
- name
747-
- namespace
748768
type: object
749769
type: object
750770
type: object

deploy/charts/github-token-manager/templates/deployment.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apps/v1
44
kind: Deployment
55
metadata:
66
name: {{ include "chart.fullname" . }}
7-
{{- with mergeOverwrite (.Values.commonAnnotations | default dict) $deployment.annotations }}
7+
{{- with mergeOverwrite (default dict .Values.commonAnnotations) (default dict $deployment.annotations) }}
88
annotations:
99
{{- range $key, $value := . }}
1010
{{ $key }}: {{ $value | quote }}
@@ -77,6 +77,10 @@ spec:
7777
- --leader-elect
7878
command:
7979
- /ko-app/manager
80+
{{- with $githubTokenManager.env }}
81+
env:
82+
{{- toYaml . | nindent 12 }}
83+
{{- end }}
8084
image: {{ $githubTokenManager.image.repository }}:{{ $githubTokenManager.image.tag }}
8185
livenessProbe:
8286
httpGet:

deploy/charts/github-token-manager/templates/rbac.yaml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@ apiVersion: v1
44
kind: ServiceAccount
55
metadata:
66
name: {{ .Values.rbac.serviceAccount.name | default (include "chart.fullname" . ) }}
7-
{{- if or .Values.rbac.serviceAccount.annotations .Values.commonAnnotations }}
7+
{{- with mergeOverwrite (default dict .Values.commonAnnotations) (default dict .Values.rbac.serviceAccount.annotations) }}
88
annotations:
9-
{{- with .Values.rbac.serviceAccount.annotations | default dict }}
10-
{{- tpl ( toYaml . ) $ | nindent 4 }}
11-
{{- end }}
12-
{{- with .Values.commonAnnotations | default dict }}
139
{{- range $key, $value := . }}
1410
{{ $key }}: {{ $value | quote }}
1511
{{- end }}
1612
{{- end }}
17-
{{- end }}
1813
labels:
1914
component: rbac
2015
{{- include "labels" . | nindent 4 }}
@@ -23,7 +18,7 @@ apiVersion: rbac.authorization.k8s.io/v1
2318
kind: Role
2419
metadata:
2520
name: {{ include "chart.fullname" . }}-leader-election-role
26-
{{- with .Values.commonAnnotations | default dict }}
21+
{{- with (default dict .Values.commonAnnotations) }}
2722
annotations:
2823
{{- range $key, $value := . }}
2924
{{ $key }}: {{ $value | quote }}
@@ -69,7 +64,7 @@ apiVersion: rbac.authorization.k8s.io/v1
6964
kind: RoleBinding
7065
metadata:
7166
name: {{ include "chart.fullname" . }}-leader-election-rolebinding
72-
{{- with .Values.commonAnnotations | default dict }}
67+
{{- with (default dict .Values.commonAnnotations) }}
7368
annotations:
7469
{{- range $key, $value := . }}
7570
{{ $key }}: {{ $value | quote }}
@@ -91,7 +86,7 @@ apiVersion: rbac.authorization.k8s.io/v1
9186
kind: ClusterRole
9287
metadata:
9388
name: {{ include "chart.fullname" . }}-role
94-
{{- with .Values.commonAnnotations | default dict }}
89+
{{- with (default dict .Values.commonAnnotations) }}
9590
annotations:
9691
{{- range $key, $value := . }}
9792
{{ $key }}: {{ $value | quote }}
@@ -177,7 +172,7 @@ apiVersion: rbac.authorization.k8s.io/v1
177172
kind: ClusterRole
178173
metadata:
179174
name: {{ include "chart.fullname" . }}-metrics-reader
180-
{{- with .Values.commonAnnotations | default dict }}
175+
{{- with (default dict .Values.commonAnnotations) }}
181176
annotations:
182177
{{- range $key, $value := . }}
183178
{{ $key }}: {{ $value | quote }}
@@ -196,7 +191,7 @@ apiVersion: rbac.authorization.k8s.io/v1
196191
kind: ClusterRole
197192
metadata:
198193
name: {{ include "chart.fullname" . }}-proxy-role
199-
{{- with .Values.commonAnnotations | default dict }}
194+
{{- with (default dict .Values.commonAnnotations) }}
200195
annotations:
201196
{{- range $key, $value := . }}
202197
{{ $key }}: {{ $value | quote }}
@@ -223,7 +218,7 @@ apiVersion: rbac.authorization.k8s.io/v1
223218
kind: ClusterRoleBinding
224219
metadata:
225220
name: {{ include "chart.fullname" . }}-rolebinding
226-
{{- with .Values.commonAnnotations }}
221+
{{- with (default dict .Values.commonAnnotations) }}
227222
annotations:
228223
{{- range $key, $value := . }}
229224
{{ $key }}: {{ $value | quote }}
@@ -245,7 +240,7 @@ apiVersion: rbac.authorization.k8s.io/v1
245240
kind: ClusterRoleBinding
246241
metadata:
247242
name: {{ include "chart.fullname" . }}-proxy-rolebinding
248-
{{- with .Values.commonAnnotations | default dict }}
243+
{{- with (default dict .Values.commonAnnotations) }}
249244
annotations:
250245
{{- range $key, $value := . }}
251246
{{ $key }}: {{ $value | quote }}

deploy/charts/github-token-manager/templates/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: v1
44
kind: Service
55
metadata:
66
name: {{ include "chart.fullname" . }}-metrics-service
7-
{{- with .Values.commonAnnotations | default dict }}
7+
{{- with (default dict .Values.commonAnnotations) }}
88
annotations:
99
{{- range $key, $value := . }}
1010
{{ $key }}: {{ $value | quote }}

deploy/charts/github-token-manager/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ namespace: ~
1818
## install: true | false
1919
## true: install the CRDs
2020
## false: do not install the CRDs
21+
## keep: true | false
22+
## true: prevent helm from deleting the CRDs when the chart is deleted
23+
## false: allow helm to delete the CRDs when the chart is deleted
2124
crds:
2225
install: true
26+
keep: true
2327

2428
## rbac
2529
## create: true | false
@@ -72,6 +76,9 @@ deployment:
7276
image:
7377
repository: ghcr.io/isometry/github-token-manager
7478
tag: latest
79+
# additional environment variables to set on the controller container
80+
# e.g. `[{name: VAULT_ADDR, value: http://vault:8200}]`
81+
env: []
7582
resources:
7683
limits:
7784
cpu: 500m

0 commit comments

Comments
 (0)