Skip to content

ansible-galaxy - Don't copy a file from a skeleton if file.j2 also exists #82624

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

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

mafalb
Copy link

@mafalb mafalb commented Jan 30, 2024

SUMMARY

If a file.j2 exists in the skeleton and also file (without .j2 extension), e.g.:

README.md
README.md.j2

ensure that only README.md.j2 is copied
This is a minor performance tweak, but there is more to it. See below...

ISSUE TYPE
  • Feature Pull Request
ADDITIONAL INFORMATION

Until now it was unspecified which file it makes into the initialized collection or role, because the directory tree is walked with os.walk() and the order is unspecified.

With the PR we have predictable results which makes some use cases possible if the skeleton is located in it's own git repository

README.md describes the usage of the skeleton and will be rendered by github UI
README.md.j2 is copied over into the collection/role

another example would be a github workflow

.github/workflows/CI.yml -> used by github actions to test my skeleton
.github/workflows/CI.yml.j2 -> template for my initialized collection/role

commands affected:

$ ansible-galaxy collection init --collection-skeleton my-skeleton local.mycollection
$ ansible-galaxy role init --role-skeleton my-role-skeleton myrole

@ansibot ansibot added feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. labels Jan 30, 2024
@mafalb mafalb changed the title ansible-galaxy - Don't copy a file from a skeleton if file.j2 also exists [WIP] - ansible-galaxy - Don't copy a file from a skeleton if file.j2 also exists Jan 30, 2024
@mafalb mafalb changed the title [WIP] - ansible-galaxy - Don't copy a file from a skeleton if file.j2 also exists ansible-galaxy - Don't copy a file from a skeleton if file.j2 also exists Jan 30, 2024
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Jan 30, 2024
@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jan 30, 2024
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jan 31, 2024
Copy link
Contributor

@s-hertel s-hertel left a comment

Choose a reason for hiding this comment

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

After discussing internally, I've changed about allowing mixing files where the skeleton lives with actual skeleton files. It's probably safest to just give an error if there are conflicting files (this will fix the bug with getting an unpredictable result), and the caller can either fix the skeleton, or use GALAXY_COLLECTION_SKELETON_IGNORE/GALAXY_ROLE_SKELETON_IGNORE if the intention is actually to ignore one of the files.

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Feb 1, 2024
@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 Feb 8, 2024
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label May 7, 2024
@ansibot ansibot added the stale_pr This PR has not been pushed to for more than one year. label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request. 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. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_pr This PR has not been pushed to for more than one year.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants