Skip to content

Commit a72f86c

Browse files
authored
Better handling of PATH env var with initConfig (#401)
* πŸ‘” add new exclusion for PATH env * ⬆️ bump chart * ⬆️ bump chart minor * ✨ Add new PATH envvar logic * βœ… Add test for new logic * πŸ“ update doc
1 parent e984db5 commit a72f86c

7 files changed

Lines changed: 81 additions & 3 deletions

File tree

β€Žcharts/atlantis/Chart.yamlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: v1
33
appVersion: v0.28.3
44
description: A Helm chart for Atlantis https://www.runatlantis.io
55
name: atlantis
6-
version: 5.2.1
6+
version: 5.3.0
77
keywords:
88
- terraform
99
home: https://www.runatlantis.io

β€Žcharts/atlantis/README.mdβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ extraManifests:
105105
| extraArgs | list | `[]` | Optionally specify extra arguments for the Atlantis pod. Check values.yaml for examples. |
106106
| extraContainers | list | `[]` | Optionally specify extra containers for the Atlantis pod. Check values.yaml for examples. |
107107
| extraManifests | list | `[]` | Optionally specify additional manifests to be created. Check values.yaml for examples. |
108+
| extraPath | string | `""` | Additional path (`:` separated) that will be appended to the system `PATH` environment variable. |
108109
| extraVolumeMounts | list | `[]` | Optionally specify additional volume mounts for the container. Check values.yaml for examples. |
109110
| extraVolumes | list | `[]` | Optionally specify additional volumes for the pod. Check values.yaml for examples. |
110111
| fullnameOverride | string | `""` | Provide a name to substitute for the full names of resources. |

β€Žcharts/atlantis/templates/_helpers.tplβ€Ž

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,16 @@ heritage: {{ .Release.Service }}
128128
{{ toYaml .Values.commonLabels }}
129129
{{- end }}
130130
{{- end -}}
131+
132+
{{/*
133+
Define PATH environment variable that will be used system-wide.
134+
*/}}
135+
{{- define "atlantis.pathEnvironmentVariable" -}}
136+
{{- if .Values.extraPath }}
137+
{{- printf "%s:" .Values.extraPath -}}
138+
{{- end -}}
139+
{{- if .Values.initConfig.sharedDir }}
140+
{{- printf "%s:" .Values.initConfig.sharedDir -}}
141+
{{- end -}}
142+
{{- printf "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" }}
143+
{{- end -}}

β€Žcharts/atlantis/templates/statefulset.yamlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ spec:
251251
{{- toYaml . | nindent 10 }}
252252
{{- end }}
253253
{{- end }}
254+
- name: PATH
255+
value: {{ template "atlantis.pathEnvironmentVariable" . }}
254256
{{- range $key, $value := .Values.environment }}
255257
- name: {{ $key }}
256258
value: {{ $value | quote }}
@@ -485,8 +487,6 @@ spec:
485487
value: {{ .Values.aws.directory }}/config
486488
{{- end }}
487489
{{- if .Values.initConfig.enabled }}
488-
- name: PATH
489-
value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:{{ .Values.initConfig.sharedDir }}
490490
- name: INIT_SHARED_DIR
491491
value: {{ .Values.initConfig.sharedDir }}
492492
{{- end }}

β€Žcharts/atlantis/tests/statefulset_test.yamlβ€Ž

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ tests:
117117
- equal:
118118
path: spec.template.spec.containers[0].env
119119
value:
120+
- name: PATH
121+
value: /plugins:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
120122
- name: ATLANTIS_DATA_DIR
121123
value: /atlantis-data
122124
- name: ATLANTIS_REPO_ALLOWLIST
@@ -895,3 +897,58 @@ tests:
895897
- equal:
896898
path: spec.template.spec.terminationGracePeriodSeconds
897899
value: 30
900+
- it: extraPath
901+
template: statefulset.yaml
902+
set:
903+
extraPath: "/foo:/bar"
904+
asserts:
905+
- equal:
906+
path: spec.template.spec.containers[0].env
907+
value:
908+
- name: PATH
909+
value: /foo:/bar:/plugins:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
910+
- name: ATLANTIS_DATA_DIR
911+
value: /atlantis-data
912+
- name: ATLANTIS_REPO_ALLOWLIST
913+
value: <replace-me>
914+
- name: ATLANTIS_PORT
915+
value: "4141"
916+
- name: ATLANTIS_ATLANTIS_URL
917+
value: http://
918+
- it: sharedDirPath
919+
template: statefulset.yaml
920+
set:
921+
initConfig.sharedDir: "/home/atlantis"
922+
asserts:
923+
- equal:
924+
path: spec.template.spec.containers[0].env
925+
value:
926+
- name: PATH
927+
value: /home/atlantis:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
928+
- name: ATLANTIS_DATA_DIR
929+
value: /atlantis-data
930+
- name: ATLANTIS_REPO_ALLOWLIST
931+
value: <replace-me>
932+
- name: ATLANTIS_PORT
933+
value: "4141"
934+
- name: ATLANTIS_ATLANTIS_URL
935+
value: http://
936+
- it: extraPathWithSharedDirPath
937+
template: statefulset.yaml
938+
set:
939+
initConfig.sharedDir: "/home/atlantis"
940+
extraPath: "/foo:/bar"
941+
asserts:
942+
- equal:
943+
path: spec.template.spec.containers[0].env
944+
value:
945+
- name: PATH
946+
value: /foo:/bar:/home/atlantis:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
947+
- name: ATLANTIS_DATA_DIR
948+
value: /atlantis-data
949+
- name: ATLANTIS_REPO_ALLOWLIST
950+
value: <replace-me>
951+
- name: ATLANTIS_PORT
952+
value: "4141"
953+
- name: ATLANTIS_ATLANTIS_URL
954+
value: http://

β€Žcharts/atlantis/values.schema.jsonβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,10 @@
866866
"type": "string",
867867
"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."
868868
},
869+
"extraPath": {
870+
"type": "string",
871+
"description": "Additional paths that will be appended to the system `PATH` environment variable. These paths should be separated with `:` to match system notation."
872+
},
869873
"environment": {
870874
"type": "object",
871875
"description": "Map of environment variables for the container.",

β€Žcharts/atlantis/values.yamlβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ enableKubernetesBackend: false
470470
# -- TLS Secret Name for Atlantis pod.
471471
tlsSecretName: ""
472472

473+
# -- Additional path (`:` separated) that will be appended to the system `PATH` environment variable.
474+
extraPath: ""
475+
473476
# -- Environtment values to add to the Atlantis pod.
474477
# Check values.yaml for examples.
475478
environment: {}

0 commit comments

Comments
Β (0)