-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(atlantis): allow .gitconfig write (#407)
* fix(atlantis): allow .gitconfig write
- Loading branch information
1 parent
18825fb
commit 58ecee7
Showing
8 changed files
with
127 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{- if not .Values.gitconfigReadOnly }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "atlantis.fullname" . }}-gitconfig-init | ||
labels: | ||
{{- include "atlantis.labels" . | nindent 4 }} | ||
{{- with .Values.extraAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
data: | ||
gitconfig-init.sh: | | ||
#!/bin/sh | ||
set -ex | ||
cp -v /etc/.gitconfig /home/atlantis/.gitconfig | ||
chown -v atlantis /home/atlantis/.gitconfig | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
suite: test configmap-gitconfig-init for gitconfig | ||
templates: | ||
- configmap-gitconfig-init.yaml | ||
release: | ||
name: my-release | ||
tests: | ||
- it: default values | ||
template: configmap-gitconfig-init.yaml | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
- it: gitconfig-read-write | ||
template: configmap-gitconfig-init.yaml | ||
set: | ||
gitconfigReadOnly: false | ||
commonLabels: | ||
team: "infra" | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: ConfigMap | ||
- isAPIVersion: | ||
of: v1 | ||
- equal: | ||
path: metadata.name | ||
value: my-release-atlantis-gitconfig-init | ||
- equal: | ||
path: data["gitconfig-init.sh"] | ||
value: | | ||
#!/bin/sh | ||
set -ex | ||
cp -v /etc/.gitconfig /home/atlantis/.gitconfig | ||
chown -v atlantis /home/atlantis/.gitconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,19 +322,19 @@ tests: | |
mountPath: /var/secrets/gcp-staging | ||
name: gcp-staging | ||
readOnly: true | ||
- it: gitconfig | ||
- it: gitconfig-read-only | ||
template: statefulset.yaml | ||
set: | ||
gitconfig: | | ||
[url "https://[email protected]"] | ||
insteadOf = https://github.com | ||
gitconfigReadOnly: true | ||
asserts: | ||
- equal: | ||
path: spec.template.spec.volumes[1] | ||
value: | ||
name: gitconfig-volume | ||
secret: | ||
defaultMode: 432 | ||
secretName: my-release-atlantis-gitconfig | ||
- equal: | ||
path: spec.template.spec.containers[0].volumeMounts[?(@.name == | ||
|
@@ -344,6 +344,45 @@ tests: | |
name: gitconfig-volume | ||
readOnly: true | ||
subPath: gitconfig | ||
- it: gitconfig-read-write | ||
template: statefulset.yaml | ||
set: | ||
gitconfig: | | ||
[url "https://[email protected]"] | ||
insteadOf = https://github.com | ||
gitconfigReadOnly: false | ||
asserts: | ||
- equal: | ||
path: spec.template.spec.volumes[?(@.name == "gitconfig-volume")] | ||
value: | ||
name: gitconfig-volume | ||
secret: | ||
secretName: my-release-atlantis-gitconfig | ||
- equal: | ||
path: spec.template.spec.volumes[?(@.name == "gitconfig-init")] | ||
value: | ||
name: gitconfig-init | ||
configMap: | ||
name: my-release-atlantis-gitconfig-init | ||
items: | ||
- key: gitconfig-init.sh | ||
path: gitconfig-init.sh | ||
mode: 0555 | ||
- equal: | ||
path: spec.template.spec.containers[0].volumeMounts[?(@.name == | ||
"gitconfig-volume")] | ||
value: | ||
mountPath: /etc/.gitconfig | ||
name: gitconfig-volume | ||
readOnly: true | ||
subPath: gitconfig | ||
- equal: | ||
path: spec.template.spec.containers[0].volumeMounts[?(@.name == | ||
"gitconfig-init")] | ||
value: | ||
mountPath: /docker-entrypoint.d/gitconfig-init.sh | ||
name: gitconfig-init | ||
subPath: gitconfig-init.sh | ||
- it: gitconfigSecretName | ||
template: statefulset.yaml | ||
set: | ||
|
@@ -354,7 +393,6 @@ tests: | |
value: | ||
name: gitconfig-volume | ||
secret: | ||
defaultMode: 432 | ||
secretName: atlantis-gitconfig | ||
- equal: | ||
path: spec.template.spec.containers[0].volumeMounts[?(@.name == | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,11 @@ gitconfig: "" | |
# insteadOf = ssh://[email protected] | ||
# Source: https://stackoverflow.com/questions/42148841/github-clone-with-oauth-access-token | ||
|
||
# -- When true gitconfig file is mounted as read only. | ||
# When false, the gitconfig value will be copied to '/home/atlantis/.gitconfig' before starting the atlantis process, | ||
# instead of being mounted as a file. | ||
gitconfigReadOnly: true | ||
|
||
# -- If managing secrets outside the chart for the gitconfig, use this variable to reference the secret name | ||
gitconfigSecretName: "" | ||
|
||
|