forked from Gitea/helm-actions
feat: allow inline yaml config instead of string literal (#43)
### Description of the change Allow to insert the act_runner config as yaml into the chart values. ### Benefits Yaml editor will report yaml errors, instead of the deployed runner. ### Possible drawbacks No limitations, string config works like before. ### Applicable issues N/A ### Additional information Usage like this, just omit the block scalar token ```yaml enabled: true statefulset: actRunner: # See full example here: https://gitea.com/gitea/act_runner/src/branch/main/internal/pkg/config/config.example.yaml config: log: level: debug cache: enabled: false container: valid_volumes: - /var/run/docker.sock options: -v /var/run/docker.sock:/var/run/docker.sock ## Specify an existing token secret ## existingSecret: "runner-token2" existingSecretKey: "token" ## Specify the root URL of the Gitea instance giteaRootURL: "http://192.168.1.2:3000" ``` I do not like the regex test approach, but I didn't come up with a better one. I wish that I can parse the nested yaml in the helm tests. ### ⚠ BREAKING N/A ### Checklist - [x] Helm templating unittests are added (required when changing anything in `templates` folder) - [x] All added template resources MUST render a namespace in metadata Reviewed-on: https://gitea.com/gitea/helm-actions/pulls/43 Reviewed-by: DaanSelen <daanselen@noreply.gitea.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de> Co-committed-by: Christopher Homberger <christopher.homberger@web.de>
This commit is contained in:

committed by
DaanSelen

parent
3b5bdc30f5
commit
bd2fcb14be
@@ -10,6 +10,10 @@ metadata:
|
|||||||
data:
|
data:
|
||||||
config.yaml: |
|
config.yaml: |
|
||||||
{{- with .Values.statefulset.actRunner.config -}}
|
{{- with .Values.statefulset.actRunner.config -}}
|
||||||
|
{{- if kindIs "string" . -}}
|
||||||
{{ . | nindent 4}}
|
{{ . | nindent 4}}
|
||||||
|
{{- else -}}
|
||||||
|
{{ toYaml . | nindent 4}}
|
||||||
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@@ -42,3 +42,27 @@ tests:
|
|||||||
runner:
|
runner:
|
||||||
labels:
|
labels:
|
||||||
- "ubuntu-latest"
|
- "ubuntu-latest"
|
||||||
|
- it: renders a ConfigMap with inline yaml
|
||||||
|
template: templates/config-act-runner.yaml
|
||||||
|
set:
|
||||||
|
enabled: true
|
||||||
|
statefulset:
|
||||||
|
actRunner:
|
||||||
|
config:
|
||||||
|
container:
|
||||||
|
valid_volumes:
|
||||||
|
- /var/run/docker.sock
|
||||||
|
options: -v /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- containsDocument:
|
||||||
|
kind: ConfigMap
|
||||||
|
apiVersion: v1
|
||||||
|
name: gitea-unittests-actions-act-runner-config
|
||||||
|
- matchRegex:
|
||||||
|
path: data["config.yaml"]
|
||||||
|
pattern: '(?m)^\s*options:\s*-v /var/run/docker.sock:/var/run/docker.sock\s*$'
|
||||||
|
- matchRegex:
|
||||||
|
path: data["config.yaml"]
|
||||||
|
pattern: '(?m)^\s*valid_volumes:\s*\n\s*-\s*/var/run/docker.sock\s*$'
|
||||||
|
Reference in New Issue
Block a user