diff --git a/templates/athens-proxy/_configMap.tpl b/templates/athens-proxy/_configMap.tpl index 9b484d7..7a80ff4 100644 --- a/templates/athens-proxy/_configMap.tpl +++ b/templates/athens-proxy/_configMap.tpl @@ -30,4 +30,10 @@ {{- if .Values.config.gitConfig.configMap.labels }} {{ toYaml .Values.config.gitConfig.configMap.labels }} {{- end }} +{{- end }} + +{{/* name */}} + +{{- define "athens-proxy.configMap.gitConfig.name" -}} +{{ include "athens-proxy.fullname" . }}-gitconfig {{- end }} \ No newline at end of file diff --git a/templates/athens-proxy/_deployment.tpl b/templates/athens-proxy/_deployment.tpl index a9b2d84..9a7b4cd 100644 --- a/templates/athens-proxy/_deployment.tpl +++ b/templates/athens-proxy/_deployment.tpl @@ -64,6 +64,10 @@ {{- $volumeMounts = concat $volumeMounts (list (dict "name" "data" "mountPath" .Values.persistence.data.mountPath)) }} {{- end }} +{{- if .Values.config.gitConfig.enabled }} +{{- $volumeMounts = concat $volumeMounts (list (dict "name" "secrets" "mountPath" "/root/.gitconfig" "subPath" ".gitconfig" )) }} +{{- end }} + {{- if .Values.config.netrc.enabled }} {{- $volumeMounts = concat $volumeMounts (list (dict "name" "secrets" "mountPath" "/root/.netrc" "subPath" ".netrc" )) }} {{- end }} @@ -84,9 +88,21 @@ {{- $volumes = concat $volumes (list (dict "name" "data" "persistentVolumeClaim" (dict "claimName" $claimName))) }} {{- end }} +{{- if .Values.config.gitConfig.enabled }} +{{- $projectedSources := list -}} +{{- $itemList := list (dict "key" ".gitconfig" "path" ".gitconfig" "mode" 0644) }} +{{- $configMapName := include "athens-proxy.configMap.gitConfig.name" . }} +{{- if .Values.config.gitConfig.existingConfigMap.enabled }} +{{- $itemList = list (dict "key" .Values.config.gitConfig.existingConfigMap.gitConfigKey "path" ".gitconfig" "mode" 0644) }} +{{- $configMapName = .Values.config.gitConfig.existingConfigMap.configMapName }} +{{- end }} +{{- $projectedSources = concat $projectedSources (list (dict "configMap" (dict "name" $configMapName "items" $itemList))) }} + +{{- $volumes = concat $volumes (list (dict "name" "secrets" "projected" (dict "sources" $projectedSources)))}} +{{- end }} + {{- if .Values.config.netrc.enabled }} {{- $projectedSources := list -}} - {{- $itemList := list (dict "key" ".netrc" "path" ".netrc" "mode" 0600) }} {{- $secretName := include "athens-proxy.secrets.netrc.name" . }} {{- if .Values.config.netrc.existingSecret.enabled }} @@ -95,7 +111,6 @@ {{- end }} {{- $projectedSources = concat $projectedSources (list (dict "secret" (dict "name" $secretName "items" $itemList))) }} - {{- $volumes = concat $volumes (list (dict "name" "secrets" "projected" (dict "sources" $projectedSources)))}} {{- end }} diff --git a/unittests/deployment/gitConfig.yaml b/unittests/deployment/gitConfig.yaml new file mode 100644 index 0000000..ca7b8ac --- /dev/null +++ b/unittests/deployment/gitConfig.yaml @@ -0,0 +1,81 @@ +chart: + appVersion: 0.1.0 + version: 0.1.0 +suite: Deployment template +release: + name: athens-proxy-unittest + namespace: testing +templates: +- templates/athens-proxy/deployment.yaml +tests: +- it: Rendering default without mounted git config map + asserts: + - notContains: + path: spec.template.spec.containers[0].volumeMounts + content: + name: secrets + mountPath: /root/.gitconfig + subPath: .gitconfig + - notContains: + path: spec.template.spec.volumes + content: + name: secrets + projected: + sources: + - configMap: + items: + - key: .gitconfig + path: .gitconfig + mode: 0600 + name: athens-proxy-unittest-gitconfig + +- it: Rendering default with mounted gitconfig configMap + set: + config.gitConfig.enabled: true + persistence.enabled: true + asserts: + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: + name: secrets + mountPath: /root/.gitconfig + subPath: .gitconfig + - contains: + path: spec.template.spec.volumes + content: + name: secrets + projected: + sources: + - configMap: + items: + - key: .gitconfig + path: .gitconfig + mode: 0644 + name: athens-proxy-unittest-gitconfig + +- it: Rendering with custom gitconfig configMap + set: + config.gitConfig.enabled: true + config.gitConfig.existingConfigMap.enabled: true + config.gitConfig.existingConfigMap.configMapName: "my-custom-configmap" + config.gitConfig.existingConfigMap.gitConfigKey: "my-gitconfig-key" + persistence.enabled: true + asserts: + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: + name: secrets + mountPath: /root/.gitconfig + subPath: .gitconfig + - contains: + path: spec.template.spec.volumes + content: + name: secrets + projected: + sources: + - configMap: + items: + - key: my-gitconfig-key + path: .gitconfig + mode: 0644 + name: my-custom-configmap \ No newline at end of file diff --git a/values.yaml b/values.yaml index cf00bc8..147fd6f 100644 --- a/values.yaml +++ b/values.yaml @@ -135,7 +135,7 @@ config: ## @param config.gitConfig.existingConfigMap.gitConfigKey The name of the key inside the config map where the content of the .gitconfig file is stored. existingConfigMap: enabled: false - secretName: "" + configMapName: "" gitConfigKey: ## @param config.gitConfig.configMap.annotations Additional annotations of the config map containing the download mode file.