From 8b7e545e13ec0f10e6da4f5cc1eafa53bf8fc41c Mon Sep 17 00:00:00 2001 From: Frederic MARTIN Date: Tue, 2 Jul 2024 14:12:33 +0200 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=91=94=20add=20new=20exclusion=20for?= =?UTF-8?q?=20PATH=20env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- charts/atlantis/templates/statefulset.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/charts/atlantis/templates/statefulset.yaml b/charts/atlantis/templates/statefulset.yaml index 5f5f7a86..ea1eb552 100644 --- a/charts/atlantis/templates/statefulset.yaml +++ b/charts/atlantis/templates/statefulset.yaml @@ -252,9 +252,14 @@ spec: {{- end }} {{- end }} {{- range $key, $value := .Values.environment }} + {{- if and ($.Values.initConfig.enabled) ($.Values.initConfig.sharedDir) (eq $key "PATH") }} + - name: PATH + value: {{ printf "%s:%s" $value $.Values.initConfig.sharedDir | quote}} + {{- else }} - name: {{ $key }} value: {{ $value | quote }} {{- end }} + {{- end }} {{- range .Values.environmentSecrets }} - name: {{ .name }} valueFrom: @@ -485,8 +490,10 @@ spec: value: {{ .Values.aws.directory }}/config {{- end }} {{- if .Values.initConfig.enabled }} + {{- if not .Values.environment.PATH }} - name: PATH value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:{{ .Values.initConfig.sharedDir }} + {{- end }} - name: INIT_SHARED_DIR value: {{ .Values.initConfig.sharedDir }} {{- end }} From c798b31f40956f134705e304ebfbe663a46d3867 Mon Sep 17 00:00:00 2001 From: Frederic MARTIN Date: Tue, 2 Jul 2024 14:14:08 +0200 Subject: [PATCH 2/6] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20bump=20chart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- charts/atlantis/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/atlantis/Chart.yaml b/charts/atlantis/Chart.yaml index 77b47afd..6c847183 100644 --- a/charts/atlantis/Chart.yaml +++ b/charts/atlantis/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v1 appVersion: v0.28.3 description: A Helm chart for Atlantis https://www.runatlantis.io name: atlantis -version: 5.2.1 +version: 5.2.2 keywords: - terraform home: https://www.runatlantis.io From 03f213cd86d6861d6b78cd4c7e6d2a0789865578 Mon Sep 17 00:00:00 2001 From: Frederic MARTIN Date: Tue, 2 Jul 2024 16:51:58 +0200 Subject: [PATCH 3/6] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20bump=20chart=20minor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- charts/atlantis/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/atlantis/Chart.yaml b/charts/atlantis/Chart.yaml index 6c847183..b2ce180c 100644 --- a/charts/atlantis/Chart.yaml +++ b/charts/atlantis/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v1 appVersion: v0.28.3 description: A Helm chart for Atlantis https://www.runatlantis.io name: atlantis -version: 5.2.2 +version: 5.3.0 keywords: - terraform home: https://www.runatlantis.io From 7a6d0052bf7d85e4d11b200173ced3db63244ee7 Mon Sep 17 00:00:00 2001 From: Frederic MARTIN Date: Tue, 2 Jul 2024 16:53:09 +0200 Subject: [PATCH 4/6] =?UTF-8?q?=E2=9C=A8=20Add=20new=20PATH=20envvar=20log?= =?UTF-8?q?ic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- charts/atlantis/templates/_helpers.tpl | 13 +++++++++++++ charts/atlantis/templates/statefulset.yaml | 11 ++--------- charts/atlantis/values.schema.json | 4 ++++ charts/atlantis/values.yaml | 3 +++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/charts/atlantis/templates/_helpers.tpl b/charts/atlantis/templates/_helpers.tpl index f4f983e6..1369ab3a 100644 --- a/charts/atlantis/templates/_helpers.tpl +++ b/charts/atlantis/templates/_helpers.tpl @@ -128,3 +128,16 @@ heritage: {{ .Release.Service }} {{ toYaml .Values.commonLabels }} {{- end }} {{- end -}} + +{{/* +Define PATH environment variable that will be used system-wide. +*/}} +{{- define "atlantis.pathEnvironmentVariable" -}} +{{- if .Values.extraPath }} +{{- printf "%s:" .Values.extraPath -}} +{{- end -}} +{{- if .Values.initConfig.sharedDir }} +{{- printf "%s:" .Values.initConfig.sharedDir -}} +{{- end -}} +{{- printf "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" }} +{{- end -}} diff --git a/charts/atlantis/templates/statefulset.yaml b/charts/atlantis/templates/statefulset.yaml index ea1eb552..595ab3d7 100644 --- a/charts/atlantis/templates/statefulset.yaml +++ b/charts/atlantis/templates/statefulset.yaml @@ -251,15 +251,12 @@ spec: {{- toYaml . | nindent 10 }} {{- end }} {{- end }} - {{- range $key, $value := .Values.environment }} - {{- if and ($.Values.initConfig.enabled) ($.Values.initConfig.sharedDir) (eq $key "PATH") }} - name: PATH - value: {{ printf "%s:%s" $value $.Values.initConfig.sharedDir | quote}} - {{- else }} + value: {{ template "atlantis.pathEnvironmentVariable" . }} + {{- range $key, $value := .Values.environment }} - name: {{ $key }} value: {{ $value | quote }} {{- end }} - {{- end }} {{- range .Values.environmentSecrets }} - name: {{ .name }} valueFrom: @@ -490,10 +487,6 @@ spec: value: {{ .Values.aws.directory }}/config {{- end }} {{- if .Values.initConfig.enabled }} - {{- if not .Values.environment.PATH }} - - name: PATH - value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:{{ .Values.initConfig.sharedDir }} - {{- end }} - name: INIT_SHARED_DIR value: {{ .Values.initConfig.sharedDir }} {{- end }} diff --git a/charts/atlantis/values.schema.json b/charts/atlantis/values.schema.json index 164e740c..2403a5d1 100644 --- a/charts/atlantis/values.schema.json +++ b/charts/atlantis/values.schema.json @@ -866,6 +866,10 @@ "type": "string", "description": "Name of a Secret for Atlantis' HTTPS certificate containing the following data items `tls.crt` with the public certificate and `tls.key` with the private key." }, + "extraPath": { + "type": "string", + "description": "Additional paths that will be appended to the system `PATH` environment variable. These paths should be separated with `:` to match system notation." + }, "environment": { "type": "object", "description": "Map of environment variables for the container.", diff --git a/charts/atlantis/values.yaml b/charts/atlantis/values.yaml index b5567c6e..8d67ad0f 100644 --- a/charts/atlantis/values.yaml +++ b/charts/atlantis/values.yaml @@ -470,6 +470,9 @@ enableKubernetesBackend: false # -- TLS Secret Name for Atlantis pod. tlsSecretName: "" +# -- Additional path (`:` separated) that will be appended to the system `PATH` environment variable. +extraPath: "" + # -- Environtment values to add to the Atlantis pod. # Check values.yaml for examples. environment: {} From fe0208924196a6595f921601eb84acc5967ebcad Mon Sep 17 00:00:00 2001 From: Frederic MARTIN Date: Tue, 2 Jul 2024 16:53:38 +0200 Subject: [PATCH 5/6] =?UTF-8?q?=E2=9C=85=20Add=20test=20for=20new=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- charts/atlantis/tests/statefulset_test.yaml | 57 +++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/charts/atlantis/tests/statefulset_test.yaml b/charts/atlantis/tests/statefulset_test.yaml index e84acc6e..ef60faa3 100644 --- a/charts/atlantis/tests/statefulset_test.yaml +++ b/charts/atlantis/tests/statefulset_test.yaml @@ -117,6 +117,8 @@ tests: - equal: path: spec.template.spec.containers[0].env value: + - name: PATH + value: /plugins:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - name: ATLANTIS_DATA_DIR value: /atlantis-data - name: ATLANTIS_REPO_ALLOWLIST @@ -895,3 +897,58 @@ tests: - equal: path: spec.template.spec.terminationGracePeriodSeconds value: 30 + - it: extraPath + template: statefulset.yaml + set: + extraPath: "/foo:/bar" + asserts: + - equal: + path: spec.template.spec.containers[0].env + value: + - name: PATH + value: /foo:/bar:/plugins:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - name: ATLANTIS_DATA_DIR + value: /atlantis-data + - name: ATLANTIS_REPO_ALLOWLIST + value: + - name: ATLANTIS_PORT + value: "4141" + - name: ATLANTIS_ATLANTIS_URL + value: http:// + - it: sharedDirPath + template: statefulset.yaml + set: + initConfig.sharedDir: "/home/atlantis" + asserts: + - equal: + path: spec.template.spec.containers[0].env + value: + - name: PATH + value: /home/atlantis:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - name: ATLANTIS_DATA_DIR + value: /atlantis-data + - name: ATLANTIS_REPO_ALLOWLIST + value: + - name: ATLANTIS_PORT + value: "4141" + - name: ATLANTIS_ATLANTIS_URL + value: http:// + - it: extraPathWithSharedDirPath + template: statefulset.yaml + set: + initConfig.sharedDir: "/home/atlantis" + extraPath: "/foo:/bar" + asserts: + - equal: + path: spec.template.spec.containers[0].env + value: + - name: PATH + value: /foo:/bar:/home/atlantis:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - name: ATLANTIS_DATA_DIR + value: /atlantis-data + - name: ATLANTIS_REPO_ALLOWLIST + value: + - name: ATLANTIS_PORT + value: "4141" + - name: ATLANTIS_ATLANTIS_URL + value: http:// From fb5a7a57ef02f151f93a7fa3b27ed7abb3256149 Mon Sep 17 00:00:00 2001 From: Frederic MARTIN Date: Tue, 2 Jul 2024 17:00:03 +0200 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=93=9D=20update=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- charts/atlantis/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/atlantis/README.md b/charts/atlantis/README.md index 02b719f3..a2384cd2 100644 --- a/charts/atlantis/README.md +++ b/charts/atlantis/README.md @@ -105,6 +105,7 @@ extraManifests: | extraArgs | list | `[]` | Optionally specify extra arguments for the Atlantis pod. Check values.yaml for examples. | | extraContainers | list | `[]` | Optionally specify extra containers for the Atlantis pod. Check values.yaml for examples. | | extraManifests | list | `[]` | Optionally specify additional manifests to be created. Check values.yaml for examples. | +| extraPath | string | `""` | Additional path (`:` separated) that will be appended to the system `PATH` environment variable. | | extraVolumeMounts | list | `[]` | Optionally specify additional volume mounts for the container. Check values.yaml for examples. | | extraVolumes | list | `[]` | Optionally specify additional volumes for the pod. Check values.yaml for examples. | | fullnameOverride | string | `""` | Provide a name to substitute for the full names of resources. |