-
Notifications
You must be signed in to change notification settings - Fork 705
Add new rule to validate pattern directory structure #4662
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
Conversation
This reverts commit 833a9ac.
eb1d2d5
to
2dde0cd
Compare
examples/collections/extensions/patterns/valid_pattern/meta/pattern.json
Show resolved
Hide resolved
df854ec
to
15b280a
Compare
15b280a
to
2f829ba
Compare
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.
🚀
Since the draft spec talks about 64 character limit to the pattern name and characters allowed, should this PR also validate that as well? |
There is a function in ansible-creator that validates pattern name early on during the scaffolding of pattern. I did not added same logic here in lint thinking it would be redundant. As per my understanding - User will first use ansible-creator to scaffold a pattern (where if pattern name does not follow the spec then it will fail right there). Then use ansible-lint to validate the same pattern. Looking for your thoughts here @samccann @ssbarnea @alisonlhart ! |
de1fee8
to
0856d3d
Compare
This MR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [pipx:ansible-lint](https://github.com/ansible/ansible-lint) ([changelog](https://github.com/ansible/ansible-lint/releases)) | `25.6.1` -> `25.7.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>ansible/ansible-lint (pipx:ansible-lint)</summary> ### [`v25.7.0`](https://github.com/ansible/ansible-lint/releases/tag/v25.7.0) [Compare Source](ansible/ansible-lint@v25.6.1...v25.7.0) #### Enhancements - Use 'x-ansible-lint' key for path patterns in schema tests ([#​4690](ansible/ansible-lint#4690)) [@​alisonlhart](https://github.com/alisonlhart) - Address disable\_lookups deprecation with ansible-core 2.19 ([#​4683](ansible/ansible-lint#4683)) [@​ssbarnea](https://github.com/ssbarnea) - Add auto-fixing implementation for pattern rule ([#​4679](ansible/ansible-lint#4679)) [@​shatakshiiii](https://github.com/shatakshiiii) - Remove patterns specific playbook meta folder ([#​4669](ansible/ansible-lint#4669)) [@​alisonlhart](https://github.com/alisonlhart) - Allow loading of yamllint config from a different location ([#​4644](ansible/ansible-lint#4644)) [@​dbrennand](https://github.com/dbrennand) - Add new rule to validate pattern directory structure ([#​4662](ansible/ansible-lint#4662)) [@​shatakshiiii](https://github.com/shatakshiiii) - Add play argspec schema validation to schema rule ([#​4667](ansible/ansible-lint#4667)) [@​alisonlhart](https://github.com/alisonlhart) - Add schema check for validating pattern specification file ([#​4653](ansible/ansible-lint#4653)) [@​shatakshiiii](https://github.com/shatakshiiii) - Enable testing with python 3.14 ([#​4637](ansible/ansible-lint#4637)) [@​ssbarnea](https://github.com/ssbarnea) #### Bugfixes - Check for gh\_action\_ref explicitly and document GHA inputs ([#​4701](ansible/ansible-lint#4701)) [@​alisonlhart](https://github.com/alisonlhart) - jinja spacing warning line-endings ([#​4691](ansible/ansible-lint#4691)) [@​anusshukla](https://github.com/anusshukla) - Handle lookup templating checks with ASTs ([#​4698](ansible/ansible-lint#4698)) [@​alisonlhart](https://github.com/alisonlhart) - Fix var-naming\[no-role-prefix] rule incorrectly applying to role variables ([#​4677](ansible/ansible-lint#4677)) [@​vills](https://github.com/vills) - schema: add missing subset 'systemd' to gather\_subset ([#​4664](ansible/ansible-lint#4664)) [@​eliba](https://github.com/eliba) - Fix typos in --list-tags help text ([#​4661](ansible/ansible-lint#4661)) [@​correctmost](https://github.com/correctmost) - Avoid import errors from filters when running in nodeps mode ([#​4651](ansible/ansible-lint#4651)) [@​ssbarnea](https://github.com/ssbarnea) #### Maintenance - packit: reformat, remove deprecated syntax and try merge queue ([#​4639](ansible/ansible-lint#4639)) [@​mfocko](https://github.com/mfocko) - Remove patch report from codecov ([#​4671](ansible/ansible-lint#4671)) [@​ssbarnea](https://github.com/ssbarnea) - Improve cspell configuration ([#​4668](ansible/ansible-lint#4668)) [@​ssbarnea](https://github.com/ssbarnea) - Update test deps ([#​4658](ansible/ansible-lint#4658)) [@​ssbarnea](https://github.com/ssbarnea) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS40NS4wIiwidXBkYXRlZEluVmVyIjoiNDEuNDUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
SUMMARY
This PR adds a new rule
pattern
for validating a sample pattern directory structure within an ansible collection.Pattern rule consists of following sub-rules -
pattern[missing-readme]
- triggers when the README.md file is missing from a pattern directory.pattern[missing-meta]
- triggers when a pattern.json spec file exists but parent meta directory is missing.pattern[missing-playbook]
- triggers when either the required playbooks directory or playbook file is missing.pattern[name-mismatch]
- triggers when pattern name does not matches with the name key in pattern.json file.Steps to validate pattern dir structure -
ansible-creator add resource pattern sample_pattern path/to/coll_proj
cd coll_proj
ansible-lint extensions/patterns/sample_pattern/meta/pattern.json
Fixes: #4665
Fixes: AAP-47360