diff --git a/README.md b/README.md index ccdfb3e..34e8ffc 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ You should be good to go! | `statefulset.actRunner.extraVolumeMounts` | Allows mounting extra volumes in the act runner container | `[]` | | `statefulset.actRunner.config` | Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details. | `Too complex. See values.yaml` | | `statefulset.dind.registry` | image registry, e.g. gcr.io,docker.io | `""` | +| `statefulset.actRunner.extraEnvs` | Allows adding custom environment variables | `[]` | | `statefulset.dind.repository` | The Docker-in-Docker image | `docker` | | `statefulset.dind.tag` | The Docker-in-Docker image tag | `28.3.3-dind` | | `statefulset.dind.digest` | Image digest. Allows to pin the given image tag. Useful for having control over mutable tags like `latest` | `""` | diff --git a/templates/statefulset.yaml b/templates/statefulset.yaml index d8af2be..6635af3 100644 --- a/templates/statefulset.yaml +++ b/templates/statefulset.yaml @@ -66,6 +66,9 @@ spec: value: /actrunner/config.yaml - name: TZ value: {{ .Values.statefulset.timezone | default "Etc/UTC" }} + {{- if .Values.statefulset.actRunner.extraEnvs }} + {{- toYaml .Values.statefulset.actRunner.extraEnvs | nindent 12 }} + {{- end }} resources: {{- toYaml .Values.statefulset.resources | nindent 12 }} volumeMounts: diff --git a/unittests/helm/statefulset.yaml b/unittests/helm/statefulset.yaml index 93d6208..12e921c 100644 --- a/unittests/helm/statefulset.yaml +++ b/unittests/helm/statefulset.yaml @@ -129,6 +129,39 @@ tests: - equal: path: spec.template.spec.initContainers[0].image value: test.io/busybox:1.37.0 + - it: renders additional environment variables for act-runner container in StatefulSet + template: templates/statefulset.yaml + set: + enabled: true + existingSecret: "my-secret" + existingSecretKey: "my-secret-key" + statefulset: + actRunner: + extraEnvs: + - name: "CUSTOM_ENV" + value: "1" + - name: "GITEA_RUNNER_NAME" + valueFrom: + fieldRef: + fieldPath: metadata.name + asserts: + - hasDocuments: + count: 1 + - containsDocument: + kind: StatefulSet + apiVersion: apps/v1 + name: gitea-unittests-actions-act-runner + - equal: + path: spec.template.spec.containers[0].env[7] + value: + name: CUSTOM_ENV + value: "1" + - matchRegex: + path: spec.template.spec.containers[0].env[8].valueFrom.fieldRef.fieldPath + pattern: "metadata\\.name" + - matchRegex: + path: spec.template.spec.containers[0].env[8].name + pattern: "GITEA_RUNNER_NAME" - it: doesn't renders a StatefulSet by default template: templates/statefulset.yaml asserts: diff --git a/values.yaml b/values.yaml index 21a9813..2d12c7f 100644 --- a/values.yaml +++ b/values.yaml @@ -22,6 +22,7 @@ ## @param statefulset.actRunner.extraVolumeMounts Allows mounting extra volumes in the act runner container ## @param statefulset.actRunner.config [default: Too complex. See values.yaml] Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details. ## @param statefulset.dind.registry image registry, e.g. gcr.io,docker.io +## @param statefulset.actRunner.extraEnvs Allows adding custom environment variables ## @param statefulset.dind.repository The Docker-in-Docker image ## @param statefulset.dind.tag The Docker-in-Docker image tag ## @param statefulset.dind.digest Image digest. Allows to pin the given image tag. Useful for having control over mutable tags like `latest` @@ -53,6 +54,12 @@ statefulset: pullPolicy: IfNotPresent fullOverride: "" extraVolumeMounts: [] + extraEnvs: + [] + # - name: "GITEA_RUNNER_NAME" + # valueFrom: + # fieldRef: + # fieldPath: metadata.name # See full example here: https://gitea.com/gitea/act_runner/src/branch/main/internal/pkg/config/config.example.yaml config: |