jedcunningham commented on code in PR #46181:
URL: https://github.com/apache/airflow/pull/46181#discussion_r1940374834
##########
airflow/dag_processing/bundles/git.py:
##########
@@ -127,8 +156,11 @@ def __init__(
self.log.error("Error creating GitHook: %s", e)
def _initialize(self):
- self._clone_bare_repo_if_required()
- self._ensure_version_in_bare_repo()
+ with self.hook.setup_inline_key() as tmp_keyfile:
Review Comment:
You'll also need to do this for refresh.
##########
airflow/dag_processing/bundles/git.py:
##########
@@ -127,8 +156,11 @@ def __init__(
self.log.error("Error creating GitHook: %s", e)
def _initialize(self):
- self._clone_bare_repo_if_required()
- self._ensure_version_in_bare_repo()
+ with self.hook.setup_inline_key() as tmp_keyfile:
+ self.hook.env = self.hook.set_git_env(tmp_keyfile)
Review Comment:
It might make sense to set `env` in the context manager for both the
key_file and private_key paths. Right now it's a bit spread out and
inconsistent. You can also rename the context manager to be a bit more general
then too.
##########
tests/dag_processing/test_dag_bundles.py:
##########
@@ -144,6 +147,17 @@ def setup_class(cls) -> None:
conn_id=CONN_ONLY_PATH,
host="path/to/repo",
conn_type="git",
+ extra={"key_file": "path/to/key"},
Review Comment:
Adding this sorta defeats the purpose - you don't need a key for a local
path :)
##########
tests/dag_processing/test_dag_bundles.py:
##########
@@ -160,6 +184,16 @@ def test_correct_repo_urls(self, conn_id,
expected_repo_url):
hook = GitHook(git_conn_id=conn_id)
assert hook.repo_url == expected_repo_url
+ def test_given_both_private_key_and_key_file(self):
+ with pytest.raises(
+ AirflowException, match="Both 'key_file' and 'private_key' cannot
be provided at the same time"
+ ):
+ GitHook(git_conn_id=CONN_BOTH_PATH_INLINE)
+
+ def test_only_inline_connection_has_tmp_keyfile(self):
Review Comment:
Looks good now I think.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]