Skip to content

Commit

Permalink
feat(chart): options to keep CRDs and set custom controller environme…
Browse files Browse the repository at this point in the history
…nt variables
  • Loading branch information
isometry committed Nov 9, 2024
1 parent 8cc5b0d commit b22f5be
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 30 deletions.
4 changes: 2 additions & 2 deletions api/v1/managed_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ type secretOwner interface {
}

type ManagedSecret struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
BasicAuth bool `json:"basicAuth"`
Namespace string `json:"namespace,omitempty"`
Name string `json:"name,omitempty"`
}

func (m ManagedSecret) IsUnset() bool {
Expand Down
2 changes: 0 additions & 2 deletions config/crd/bases/github.as-code.io_clustertokens.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ spec:
type: string
required:
- basicAuth
- name
- namespace
type: object
type: object
type: object
Expand Down
2 changes: 0 additions & 2 deletions config/crd/bases/github.as-code.io_tokens.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ spec:
type: string
required:
- basicAuth
- name
- namespace
type: object
type: object
type: object
Expand Down
8 changes: 7 additions & 1 deletion deploy/charts/github-token-manager/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v1
kind: Secret
metadata:
name: gtm-config
{{- with .Values.commonAnnotations | default dict }}
{{- with (default dict .Values.commonAnnotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand All @@ -18,5 +18,11 @@ stringData:
app_id: {{ .Values.config.app_id | int }}
installation_id: {{ .Values.config.installation_id | int }}
provider: "{{ .Values.config.provider }}"
{{- if ne .Values.config.provider "file" }}
key: "{{ .Values.config.key }}"
{{- else }}
key: /config/private.key
private.key: |
{{- .Values.config.key | nindent 4 }}
{{- end }}
{{- end }}
36 changes: 28 additions & 8 deletions deploy/charts/github-token-manager/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: clustertokens.github.as-code.io
{{- with .Values.commonAnnotations | default dict }}
{{- with mergeOverwrite (default dict .Values.commonAnnotations) (ternary (dict "helm.sh/resource-policy" "keep") (dict) .Values.crds.keep) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand Down Expand Up @@ -268,11 +268,23 @@ spec:
type: array
secret:
properties:
annotations:
additionalProperties:
type: string
description:
Extra annotations for the Secret managed by this
Token
type: object
basicAuth:
description:
Create a secret with 'username' and 'password' fields
for HTTP Basic Auth rather than simply 'token'
type: boolean
labels:
additionalProperties:
type: string
description: Extra labels for the Secret managed by this Token
type: object
name:
description:
Name for the Secret managed by this ClusterToken
Expand Down Expand Up @@ -369,8 +381,6 @@ spec:
type: string
required:
- basicAuth
- name
- namespace
type: object
type: object
type: object
Expand All @@ -383,7 +393,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: tokens.github.as-code.io
{{- with .Values.commonAnnotations | default dict }}
{{- with mergeOverwrite (default dict .Values.commonAnnotations) (ternary (dict "helm.sh/resource-policy" "keep") (dict) .Values.crds.keep) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand Down Expand Up @@ -648,15 +658,27 @@ spec:
secret:
description: Override the default token secret name and type
properties:
annotations:
additionalProperties:
type: string
description:
Extra annotations for the Secret managed by this
Token
type: object
basicAuth:
description:
Create a secret with 'username' and 'password' fields
for HTTP Basic Auth rather than simply 'token'
type: boolean
labels:
additionalProperties:
type: string
description: Extra labels for the Secret managed by this Token
type: object
name:
description:
Name for the Secret managed by this ClusterToken
(defaults to the name of the Token)
Name for the Secret managed by this Token (defaults
to the name of the Token)
maxLength: 253
type: string
type: object
Expand Down Expand Up @@ -743,8 +765,6 @@ spec:
type: string
required:
- basicAuth
- name
- namespace
type: object
type: object
type: object
Expand Down
6 changes: 5 additions & 1 deletion deploy/charts/github-token-manager/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "chart.fullname" . }}
{{- with mergeOverwrite (.Values.commonAnnotations | default dict) $deployment.annotations }}
{{- with mergeOverwrite (default dict .Values.commonAnnotations) (default dict $deployment.annotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand Down Expand Up @@ -77,6 +77,10 @@ spec:
- --leader-elect
command:
- /ko-app/manager
{{- with $githubTokenManager.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
image: {{ $githubTokenManager.image.repository }}:{{ $githubTokenManager.image.tag }}
livenessProbe:
httpGet:
Expand Down
21 changes: 8 additions & 13 deletions deploy/charts/github-token-manager/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.rbac.serviceAccount.name | default (include "chart.fullname" . ) }}
{{- if or .Values.rbac.serviceAccount.annotations .Values.commonAnnotations }}
{{- with mergeOverwrite (default dict .Values.commonAnnotations) (default dict .Values.rbac.serviceAccount.annotations) }}
annotations:
{{- with .Values.rbac.serviceAccount.annotations | default dict }}
{{- tpl ( toYaml . ) $ | nindent 4 }}
{{- end }}
{{- with .Values.commonAnnotations | default dict }}
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
labels:
component: rbac
{{- include "labels" . | nindent 4 }}
Expand All @@ -23,7 +18,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "chart.fullname" . }}-leader-election-role
{{- with .Values.commonAnnotations | default dict }}
{{- with (default dict .Values.commonAnnotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand Down Expand Up @@ -69,7 +64,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "chart.fullname" . }}-leader-election-rolebinding
{{- with .Values.commonAnnotations | default dict }}
{{- with (default dict .Values.commonAnnotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand All @@ -91,7 +86,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "chart.fullname" . }}-role
{{- with .Values.commonAnnotations | default dict }}
{{- with (default dict .Values.commonAnnotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand Down Expand Up @@ -177,7 +172,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "chart.fullname" . }}-metrics-reader
{{- with .Values.commonAnnotations | default dict }}
{{- with (default dict .Values.commonAnnotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand All @@ -196,7 +191,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "chart.fullname" . }}-proxy-role
{{- with .Values.commonAnnotations | default dict }}
{{- with (default dict .Values.commonAnnotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand All @@ -223,7 +218,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "chart.fullname" . }}-rolebinding
{{- with .Values.commonAnnotations }}
{{- with (default dict .Values.commonAnnotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand All @@ -245,7 +240,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "chart.fullname" . }}-proxy-rolebinding
{{- with .Values.commonAnnotations | default dict }}
{{- with (default dict .Values.commonAnnotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand Down
2 changes: 1 addition & 1 deletion deploy/charts/github-token-manager/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "chart.fullname" . }}-metrics-service
{{- with .Values.commonAnnotations | default dict }}
{{- with (default dict .Values.commonAnnotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
Expand Down
7 changes: 7 additions & 0 deletions deploy/charts/github-token-manager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ namespace: ~
## install: true | false
## true: install the CRDs
## false: do not install the CRDs
## keep: true | false
## true: prevent helm from deleting the CRDs when the chart is deleted
## false: allow helm to delete the CRDs when the chart is deleted
crds:
install: true
keep: true

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

0 comments on commit b22f5be

Please sign in to comment.