Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
{{- if or (and .Values.dags.gitSync.enabled (not .Values.dags.persistence.enabled)) .Values.workers.extraInitContainers }}
initContainers:
{{- if and .Values.dags.gitSync.enabled (not .Values.dags.persistence.enabled) }}
{{- include "git_sync_container" (dict "Values" .Values "is_init" "true" "Template" .Template) | nindent 4 }}
{{- include "git_sync_container" (merge . (dict "is_init" "true")) | nindent 4 }}
{{- end }}
{{- if .Values.workers.extraInitContainers }}
{{- toYaml .Values.workers.extraInitContainers | nindent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ If release name contains chart name it will be used as a full name.
- name: GIT_SYNC_BRANCH
value: {{ .Values.dags.gitSync.branch | quote }}
- name: GIT_SYNC_REPO
value: {{ .Values.dags.gitSync.repo | quote }}
value: {{ tpl .Values.dags.gitSync.repo . | quote }}
- name: GITSYNC_REPO
value: {{ .Values.dags.gitSync.repo | quote }}
value: {{ tpl .Values.dags.gitSync.repo . | quote }}
- name: GIT_SYNC_DEPTH
value: {{ .Values.dags.gitSync.depth | quote }}
- name: GITSYNC_DEPTH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ spec:
{{- end }}
{{- end }}
{{- if and (.Values.dags.gitSync.enabled) (not .Values.dags.persistence.enabled) }}
{{- include "git_sync_container" (dict "Values" .Values "is_init" "true" "Template" .Template) | nindent 8 }}
{{- include "git_sync_container" (merge . (dict "is_init" "true")) | nindent 8 }}
{{- end }}
{{- if .Values.dagProcessor.extraInitContainers }}
{{- toYaml .Values.dagProcessor.extraInitContainers | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ spec:
{{- end }}
{{- end }}
{{- if and $localOrDagProcessorDisabled .Values.dags.gitSync.enabled }}
{{- include "git_sync_container" (dict "Values" .Values "is_init" "true" "Template" .Template) | nindent 8 }}
{{- include "git_sync_container" (merge . (dict "is_init" "true")) | nindent 8 }}
{{- end }}
{{- if .Values.scheduler.extraInitContainers }}
{{- toYaml .Values.scheduler.extraInitContainers | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/triggerer/triggerer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ spec:
{{- end }}
{{- end }}
{{- if and (.Values.dags.gitSync.enabled) (not .Values.dags.persistence.enabled) }}
{{- include "git_sync_container" (dict "Values" .Values "is_init" "true" "Template" .Template) | nindent 8 }}
{{- include "git_sync_container" (merge . (dict "is_init" "true")) | nindent 8 }}
{{- end }}
{{- if .Values.triggerer.extraInitContainers }}
{{- toYaml .Values.triggerer.extraInitContainers | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/webserver/webserver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ spec:
{{- end }}
{{- end }}
{{- if and (.Values.dags.gitSync.enabled) (not .Values.dags.persistence.enabled) (semverCompare "<2.0.0" .Values.airflowVersion) }}
{{- include "git_sync_container" (dict "Values" .Values "is_init" "true" "Template" .Template) | nindent 8 }}
{{- include "git_sync_container" (merge . (dict "is_init" "true")) | nindent 8 }}
{{- end }}
{{- if .Values.webserver.extraInitContainers }}
{{- toYaml .Values.webserver.extraInitContainers | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ spec:
{{- end }}
{{- end }}
{{- if and (.Values.dags.gitSync.enabled) (not .Values.dags.persistence.enabled) }}
{{- include "git_sync_container" (dict "Values" .Values "is_init" "true" "Template" .Template) | nindent 8 }}
{{- include "git_sync_container" (merge . (dict "is_init" "true")) | nindent 8 }}
{{- end }}
{{- if .Values.workers.extraInitContainers }}
{{- toYaml .Values.workers.extraInitContainers | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2451,7 +2451,7 @@ dags:
gitSync:
enabled: false

# git repo clone url
# git repo clone url (can be templated)
# ssh example: git@github.com:apache/airflow.git
# https example: https://github.com/apache/airflow.git
repo: https://github.com/apache/airflow.git
Expand Down
27 changes: 27 additions & 0 deletions helm_tests/other/test_git_sync_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,30 @@ def test_resources_are_configurable(self):
"spec.template.spec.containers[1].resources.requests.memory", docs[0]
)
assert "300m" == jmespath.search("spec.template.spec.containers[1].resources.requests.cpu", docs[0])

def test_can_repo_url_be_templated(self):
docs = render_chart(
values={
"testValues": {
"dict": {
"key": "aa",
},
},
"dags": {
"gitSync": {
"enabled": True,
"repo": "https://github.com/{{ .Values.testValues.dict.key }}/{{ .Release.Namespace }}.git",
}
},
},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
namespace="bb",
)

assert {"name": "GIT_SYNC_REPO", "value": "https://github.com/aa/bb.git"} in jmespath.search(
"spec.template.spec.containers[1].env", docs[0]
)

assert {"name": "GITSYNC_REPO", "value": "https://github.com/aa/bb.git"} in jmespath.search(
"spec.template.spec.containers[1].env", docs[0]
)
27 changes: 27 additions & 0 deletions helm_tests/other/test_git_sync_triggerer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,30 @@ def test_validate_sshkeysecret_not_added_when_persistence_is_enabled(self):
show_only=["templates/triggerer/triggerer-deployment.yaml"],
)
assert "git-sync-ssh-key" not in jmespath.search("spec.template.spec.volumes[].name", docs[0])

def test_can_repo_url_be_templated(self):
docs = render_chart(
values={
"testValues": {
"dict": {
"key": "aa",
},
},
"dags": {
"gitSync": {
"enabled": True,
"repo": "https://github.com/{{ .Values.testValues.dict.key }}/{{ .Release.Namespace }}.git",
}
},
},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
namespace="bb",
)

assert {"name": "GIT_SYNC_REPO", "value": "https://github.com/aa/bb.git"} in jmespath.search(
"spec.template.spec.containers[1].env", docs[0]
)

assert {"name": "GITSYNC_REPO", "value": "https://github.com/aa/bb.git"} in jmespath.search(
"spec.template.spec.containers[1].env", docs[0]
)
27 changes: 27 additions & 0 deletions helm_tests/other/test_git_sync_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,30 @@ def test_validate_sshkeysecret_not_added_when_persistence_is_enabled(self):
show_only=["templates/webserver/webserver-deployment.yaml"],
)
assert "git-sync-ssh-key" not in jmespath.search("spec.template.spec.volumes[].name", docs[0])

def test_can_repo_url_be_templated(self):
docs = render_chart(
values={
"testValues": {
"dict": {
"key": "aa",
},
},
"dags": {
"gitSync": {
"enabled": True,
"repo": "https://github.com/{{ .Values.testValues.dict.key }}/{{ .Release.Namespace }}.git",
}
},
},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
namespace="bb",
)

assert {"name": "GIT_SYNC_REPO", "value": "https://github.com/aa/bb.git"} in jmespath.search(
"spec.template.spec.containers[1].env", docs[0]
)

assert {"name": "GITSYNC_REPO", "value": "https://github.com/aa/bb.git"} in jmespath.search(
"spec.template.spec.containers[1].env", docs[0]
)
27 changes: 27 additions & 0 deletions helm_tests/other/test_git_sync_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,30 @@ def test_validate_sshkeysecret_not_added_when_persistence_is_enabled(self):
)

assert "git-sync-ssh-key" not in jmespath.search("spec.template.spec.volumes[].name", docs[0])

def test_can_repo_url_be_templated(self):
docs = render_chart(
values={
"testValues": {
"dict": {
"key": "aa",
},
},
"dags": {
"gitSync": {
"enabled": True,
"repo": "https://github.com/{{ .Values.testValues.dict.key }}/{{ .Release.Namespace }}.git",
}
},
},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
namespace="bb",
)

assert {"name": "GIT_SYNC_REPO", "value": "https://github.com/aa/bb.git"} in jmespath.search(
"spec.template.spec.containers[1].env", docs[0]
)

assert {"name": "GITSYNC_REPO", "value": "https://github.com/aa/bb.git"} in jmespath.search(
"spec.template.spec.containers[1].env", docs[0]
)