Skip to content

Commit bd2fcb1

Browse files
ChristopherHXDaanSelen
authored andcommitted
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>
1 parent 3b5bdc3 commit bd2fcb1

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

templates/config-act-runner.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ metadata:
1010
data:
1111
config.yaml: |
1212
{{- with .Values.statefulset.actRunner.config -}}
13+
{{- if kindIs "string" . -}}
1314
{{ . | nindent 4}}
15+
{{- else -}}
16+
{{ toYaml . | nindent 4}}
17+
{{- end -}}
1418
{{- end -}}
1519
{{- end }}

unittests/helm/config-act-runner.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,27 @@ tests:
4242
runner:
4343
labels:
4444
- "ubuntu-latest"
45+
- it: renders a ConfigMap with inline yaml
46+
template: templates/config-act-runner.yaml
47+
set:
48+
enabled: true
49+
statefulset:
50+
actRunner:
51+
config:
52+
container:
53+
valid_volumes:
54+
- /var/run/docker.sock
55+
options: -v /var/run/docker.sock:/var/run/docker.sock
56+
asserts:
57+
- hasDocuments:
58+
count: 1
59+
- containsDocument:
60+
kind: ConfigMap
61+
apiVersion: v1
62+
name: gitea-unittests-actions-act-runner-config
63+
- matchRegex:
64+
path: data["config.yaml"]
65+
pattern: '(?m)^\s*options:\s*-v /var/run/docker.sock:/var/run/docker.sock\s*$'
66+
- matchRegex:
67+
path: data["config.yaml"]
68+
pattern: '(?m)^\s*valid_volumes:\s*\n\s*-\s*/var/run/docker.sock\s*$'

0 commit comments

Comments
 (0)