Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

ssbarnea
Copy link
Member

SUMMARY

Fix bug where ansible-galaxy install would fail when given paths starting with tilde (user home).

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

galaxy

ADDITIONAL INFORMATION

Related: ansible/galaxy#2030

@ansibot ansibot added affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. docs This issue/PR relates to or includes documentation. needs_triage Needs a first human triage before being processed. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jul 28, 2020
@ssbarnea
Copy link
Member Author

ssbarnea commented Jul 28, 2020

@awcrosby @webknjaz @samccann @sivel please check ^

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jul 28, 2020
@webknjaz
Copy link
Member

@ssbarnea this needs a change note file in order to get merged

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. small_patch labels Jul 28, 2020
@webknjaz webknjaz closed this Jul 28, 2020
@webknjaz webknjaz reopened this Jul 28, 2020
@ansibot ansibot added the support:community This issue/PR relates to code supported by the Ansible community. label Jul 28, 2020
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. and removed core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jul 28, 2020
@gundalow gundalow requested a review from jborean93 July 29, 2020 10:02
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jul 29, 2020
@webknjaz
Copy link
Member

/me just restarted the failed job

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jul 29, 2020
@acozine acozine added P3 Priority 3 - Approved, No Time Limitation and removed needs_triage Needs a first human triage before being processed. labels Jul 30, 2020
@@ -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)
Copy link
Contributor

@samdoran samdoran Jul 30, 2020

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.

@samdoran
Copy link
Contributor

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.

@bcoca
Copy link
Member

bcoca commented Jul 30, 2020

we should also discuss if $HOME and other variable support (move to unfrackpath?)

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Aug 7, 2020
@ssbarnea
Copy link
Member Author

ssbarnea commented Nov 3, 2020

@bcoca @samdoran I do not know how to use unfrack_path as I seen it used only as a type for command line.

@bcoca
Copy link
Member

bcoca commented Nov 3, 2020

just import and use as a normal python function
https://github.com/ansible/ansible/blob/devel/lib/ansible/utils/path.py#L31

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.src = os.path.expanduser(src or name)
from ansible.utils.path import unfrackpath
...
self.src = unfrackpath(src or name)

Copy link
Contributor

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
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. core_review In order to be merged, this PR must follow the core review workflow. labels Nov 3, 2020
@samdoran samdoran added the ci_verified Changes made in this PR are causing tests to fail. label Nov 4, 2020
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Nov 12, 2020
@ansibot ansibot added pre_azp This PR was last tested before migration to Azure Pipelines. and removed ci_verified Changes made in this PR are causing tests to fail. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Dec 6, 2020
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Jan 7, 2021
@@ -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
Copy link
Contributor

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)
Copy link
Contributor

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.

@ansibot ansibot removed the support:community This issue/PR relates to code supported by the Ansible community. label Mar 5, 2021
@ssbarnea ssbarnea closed this Apr 8, 2022
@ansible ansible locked and limited conversation to collaborators Apr 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.11 bug This issue/PR relates to a bug. docs This issue/PR relates to or includes documentation. needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. P3 Priority 3 - Approved, No Time Limitation pre_azp This PR was last tested before migration to Azure Pipelines. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
No open projects
ansible-base 2.10
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

8 participants