Jie211 commented on code in PR #73662:
URL: https://github.com/apache/airflow/pull/73662#discussion_r4102843186
##########
providers/git/src/airflow/providers/git/hooks/git.py:
##########
@@ -154,20 +161,36 @@ def __init__(
if all(github_app_fields):
if self.auth_token:
raise ValueError("Password field must be empty to use GitHub
App Auth")
- if not (self.repo_url or "").startswith(("https://", "http://")):
+ repo_url = self.repo_url or ""
+ if not repo_url.startswith(("https://", "http://")):
raise ValueError(
f"GitHub App authentication requires an HTTPS repository
URL, but got: {self.repo_url!r}"
)
+ self.github_api_url = extra.get("github_api_url")
+ if not self.github_api_url:
+ repo_host = urlsplit(repo_url).hostname or ""
+ if repo_host != "github.com":
+ raise ValueError(
+ f"GitHub App authentication against {repo_host!r}
requires 'github_api_url' "
+ "in the connection extra. The default API URL only
serves repositories "
+ "on 'github.com'."
+ )
+ self.github_api_url = _DEFAULT_GITHUB_API_URL
if self.key_file and not self.private_key:
with open(self.key_file, encoding="utf-8") as key_file:
self.private_key = key_file.read()
_VALID_STRICT_HOST_KEY_CHECKING = frozenset({"yes", "no", "accept-new",
"off", "ask"})
_SSH_REPO_URL_PATTERN = re.compile(r"^[^/@:]+@[^/:]+:")
+ def _uses_github_app_auth(self) -> bool:
+ return bool(self.github_app_id and self.github_installation_id)
+
def _uses_ssh_transport_options(self) -> bool:
# Heuristic: any SSH-specific option implies SSH; otherwise fall back
to the URL scheme.
# A bare ssh-config Host alias (no ``user@``) without SSH options is
not detected.
+ if self._uses_github_app_auth():
+ return False
Review Comment:
I got it, that makes sense.
I added the doc explanation, and removed the test that was checking for that
warning.
--
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]