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
Expand user home on galaxy install src #70942
Conversation
@ssbarnea this needs a change note file in order to get merged |
2fba277
to
c8aeede
Compare
c8aeede
to
5368b32
Compare
/me just restarted the failed job |
lib/ansible/galaxy/role.py
Outdated
@@ -64,7 +64,7 @@ def __init__(self, galaxy, api, name, src=None, version=None, scm=None, path=Non | |||
|
|||
self.name = name | |||
self.version = version | |||
self.src = src or name | |||
self.src = os.path.expanduser(src or name) |
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.
This should use ansible.utils.path.unfrackpath
.
I read through the code and I think think it will be ok. I would like to have tests. We should also make sure this works for collections (if it doesn't already) so we can maintain feature parity. |
we should also discuss if |
just import and use as a normal python function |
lib/ansible/galaxy/role.py
Outdated
@@ -64,7 +64,7 @@ def __init__(self, galaxy, api, name, src=None, version=None, scm=None, path=Non | |||
|
|||
self.name = name | |||
self.version = version | |||
self.src = src or name | |||
self.src = os.path.expanduser(src or name) |
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.
self.src = os.path.expanduser(src or name) | |
from ansible.utils.path import unfrackpath | |
... | |
self.src = unfrackpath(src or name) |
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.
Sorry I gave you the wrong function name (unfrack_path
) initially.
Fix bug where ansible-galaxy install would fail when given paths starting with tilde (user home). Related: ansible/galaxy#2030
b5e04c1
to
2a449c6
Compare
@@ -272,6 +272,9 @@ Use the following example as a guide for specifying roles in *requirements.yml*: | |||
|
|||
# from locally cloned git repository (file:// requires full paths) | |||
- src: file:///home/bennojoy/nginx | |||
|
|||
# from locally cloned 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.
This wording might be confusing since we have particular syntax for repos. The example above was recently changed 7762741.
# from local path
is maybe clearer
@@ -64,7 +65,7 @@ def __init__(self, galaxy, api, name, src=None, version=None, scm=None, path=Non | |||
|
|||
self.name = name | |||
self.version = version | |||
self.src = src or name | |||
self.src = unfrackpath(src or name) |
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.
We could be using unfrackpath on a URL, git repo, or something that provides an absolute path prefixed with file://. This would break those scenarios since we automatically prepend a base dir in unfrackpath.
>>> from ansible.utils.path import unfrackpath
>>> unfrackpath('https://github.com/')
'/home/shertel/ansible/https:/github.com'
>>> unfrackpath('file:///path')
'/home/shertel/ansible/file:/path'
>>> unfrackpath('git+file:///path')
'/home/shertel/ansible/git+file:/path'
We might be able to move this somewhere that's only supposed to handle directories, or your original os.path.expanduser()
may be a better choice.
This definitely needs tests.
SUMMARY
Fix bug where ansible-galaxy install would fail when given paths starting with tilde (user home).
ISSUE TYPE
COMPONENT NAME
galaxy
ADDITIONAL INFORMATION
Related: ansible/galaxy#2030