-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add view_url for DagBundles #45126
base: main
Are you sure you want to change the base?
Add view_url for DagBundles #45126
Conversation
This PR adds view_url to Dagbundles to enable viewing the bundle's version
7bdbe1e
to
bcc7524
Compare
if not version: | ||
raise AirflowException("Version is required to view the repository") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typing allowing none versions, but having it always raise, feels a bit awkward. Perhaps we just return none in this case?
if not self._has_version(self.repo, version): | ||
raise AirflowException(f"Version {version} not found in the repository") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we should even check - we are just building a url, let the other side display a 404.
if self.repo_url.startswith("git@"): | ||
parts = self.repo_url.split(":") | ||
domain = parts[0].replace("git@", "https://") | ||
repo_path = parts[1].replace(".git", "") | ||
return f"{domain}/{repo_path}" | ||
raise ValueError(f"Invalid git SSH URL: {self.repo_url}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.repo_url.startswith("git@"): | |
parts = self.repo_url.split(":") | |
domain = parts[0].replace("git@", "https://") | |
repo_path = parts[1].replace(".git", "") | |
return f"{domain}/{repo_path}" | |
raise ValueError(f"Invalid git SSH URL: {self.repo_url}") | |
if not self.repo_url.startswith("git@"): | |
raise ValueError(f"Invalid git SSH URL: {self.repo_url}") | |
parts = self.repo_url.split(":") | |
domain = parts[0].replace("git@", "https://") | |
repo_path = parts[1].replace(".git", "") | |
return f"{domain}/{repo_path}" |
url = self._convert_git_ssh_url_to_https() | ||
if url.endswith(".git"): | ||
url = url[:-4] | ||
if "github" in url: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if "github" in url: | |
if url.startswith("https://github.com"): |
I wonder if this might be a bit more resilient?
url = self.repo_url | ||
if url.startswith("git@"): | ||
url = self._convert_git_ssh_url_to_https() | ||
if url.startswith("https://github.com"): |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
https://github.com
url = self._convert_git_ssh_url_to_https() | ||
if url.startswith("https://github.com"): | ||
return f"{url}/tree/{version}" | ||
if url.startswith("https://gitlab.com"): |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
https://gitlab.com
return f"{url}/tree/{version}" | ||
if url.startswith("https://gitlab.com"): | ||
return f"{url}/-/tree/{version}" | ||
if url.startswith("https://bitbucket.org"): |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
This PR adds view_url to Dagbundles to enable viewing the bundle's version