From 5fffd3d5cdaaed9874a7ae15c173c70925bd7680 Mon Sep 17 00:00:00 2001 From: Subham Sangwan Date: Tue, 19 May 2026 15:59:26 +0530 Subject: [PATCH] Chart: Make git-sync link directory configurable --- chart/docs/manage-dag-files.rst | 4 ++++ chart/templates/_helpers.yaml | 8 ++++---- chart/values.schema.json | 5 +++++ chart/values.yaml | 5 +++++ .../helm_tests/airflow_aux/test_configmap.py | 15 +++++++++++++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/chart/docs/manage-dag-files.rst b/chart/docs/manage-dag-files.rst index 3ab6529565435..05cda545f3ab7 100644 --- a/chart/docs/manage-dag-files.rst +++ b/chart/docs/manage-dag-files.rst @@ -108,6 +108,10 @@ This option will always use running Git-Sync sidecar on every dag-processor, wor The Git-Sync sidecar containers will sync Dags from a git repository every configured number of seconds. If you are using the ``KubernetesExecutor``, Git-Sync will run as an init container on your worker pods. +If you want the synced files to appear under a different directory name than ``repo`` inside the Dag mount path, +set ``dags.gitSync.link`` in your ``values.yaml``. For example, ``link: myrepo`` will mount Dags under +``$AIRFLOW_HOME/dags/myrepo`` instead of ``$AIRFLOW_HOME/dags/repo``. + .. code-block:: bash helm upgrade --install airflow apache-airflow/airflow \ diff --git a/chart/templates/_helpers.yaml b/chart/templates/_helpers.yaml index 42bd5cfa4320b..b98381994d41a 100644 --- a/chart/templates/_helpers.yaml +++ b/chart/templates/_helpers.yaml @@ -241,9 +241,9 @@ If release name contains chart name it will be used as a full name. - name: GITSYNC_ROOT value: "/git" - name: GIT_SYNC_DEST - value: "repo" + value: {{ default "repo" .Values.dags.gitSync.link | quote }} - name: GITSYNC_LINK - value: "repo" + value: {{ default "repo" .Values.dags.gitSync.link | quote }} - name: GIT_SYNC_ADD_USER value: "true" - name: GITSYNC_ADD_USER @@ -590,13 +590,13 @@ server_tls_key_file = /etc/pgbouncer/server.key {{- define "airflow_dags" -}} {{- if .Values.dags.mountPath }} {{- if .Values.dags.gitSync.enabled }} - {{- printf "%s/repo/%s" .Values.dags.mountPath .Values.dags.gitSync.subPath }} + {{- printf "%s/%s/%s" .Values.dags.mountPath (default "repo" .Values.dags.gitSync.link) .Values.dags.gitSync.subPath }} {{- else }} {{- printf "%s" .Values.dags.mountPath }} {{- end }} {{- else }} {{- if .Values.dags.gitSync.enabled }} - {{- printf "%s/dags/repo/%s" .Values.airflowHome .Values.dags.gitSync.subPath }} + {{- printf "%s/dags/%s/%s" .Values.airflowHome (default "repo" .Values.dags.gitSync.link) .Values.dags.gitSync.subPath }} {{- else }} {{- printf "%s/dags" .Values.airflowHome }} {{- end }} diff --git a/chart/values.schema.json b/chart/values.schema.json index cadc5e9d75de3..6fdd2fcf5ca0b 100644 --- a/chart/values.schema.json +++ b/chart/values.schema.json @@ -11908,6 +11908,11 @@ "type": "integer", "default": 1 }, + "link": { + "description": "Name of the directory where git-sync will create the symlink to the checked out repository. This allows customization of the DAG mount path structure.", + "type": "string", + "default": "repo" + }, "maxFailures": { "description": "The number of consecutive failures allowed before aborting.", "type": "integer", diff --git a/chart/values.yaml b/chart/values.yaml index 1fe6b159a29d0..48a86da6e8c9e 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -4347,6 +4347,11 @@ dags: # Should be "" if dags are at repo root subPath: "tests/dags" + # Name of the directory where git-sync will create the symlink to the checked out repository. + # This allows customization of the DAG mount path structure. + # Default is "repo" for backward compatibility. + link: "repo" + # If your repo needs a username/password, you can load them to a k8s secret # # credentialsSecret: git-credentials diff --git a/helm-tests/tests/helm_tests/airflow_aux/test_configmap.py b/helm-tests/tests/helm_tests/airflow_aux/test_configmap.py index 54c5518636381..03b4c79c5350f 100644 --- a/helm-tests/tests/helm_tests/airflow_aux/test_configmap.py +++ b/helm-tests/tests/helm_tests/airflow_aux/test_configmap.py @@ -183,6 +183,21 @@ def test_overridedn_flower_url_prefix(self): {"mountPath": "/opt/airflow/dags/custom", "persistence": {"enabled": True}}, "/opt/airflow/dags/custom", ), + ( + # Test custom link name with default mountPath + {"gitSync": {"enabled": True, "link": "myrepo"}}, + "/opt/airflow/dags/myrepo/tests/dags", + ), + ( + # Test custom link with custom mountPath + {"mountPath": "/opt/airflow/dags/custom", "gitSync": {"enabled": True, "link": "customrepo"}}, + "/opt/airflow/dags/custom/customrepo/tests/dags", + ), + ( + # Test custom link with subPath + {"gitSync": {"enabled": True, "link": "myrepo", "subPath": "mysubPath"}}, + "/opt/airflow/dags/myrepo/mysubPath", + ), ], ) def test_expected_default_dag_folder(self, dag_values, expected_default_dag_folder):