Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix role name handling in prerun.py (#1490)
* src/ansiblelint/prerun.py: Fix role name from SCM According to https://galaxy.ansible.com/docs/contributing/creating_role.html#role-metadata: "role_name is not used at all if the role is installed using its Git URL. Instead, the name of the repo is used." So, make _install_galaxy_role() respect this to compute the role name. To avoid importing ansible galaxy files, the SCM list is hardcoded to git or hg. Signed-off-by: Arnaud Patard <[email protected]> * src/ansiblelint/prerun.py: Use computed fqrn in _install_galaxy_role() _install_galaxy_role() is taking great pain to get and check the fqrn, even handling/using the shortname when the 'role-name' check is in skip_list but the code is not using the fqrn value to create the symlink in .cache/roles. Correct this by using the computed fqrn name for the link name. Signed-off-by: Arnaud Patard <[email protected]> * playbooks/eco.yml: Change geerlingguy.mysql checkout path Change the ansible-role-mysql git clone path to match the role fqrn as it's what's used with galaxy and what's currently done by the role ci. (ref: https://github.com/geerlingguy/ansible-role-mysql/blob/86ffba892e1553b7e6f042ec007eef25daa8f5db/.github/workflows/ci.yml#L21) Signed-off-by: Arnaud Patard <[email protected]> * Keep testing both folder names * src/ansiblelint/prerun.py: Try to handle author name in metadata author If the author field in meta/main.yml looks like "John Doe" (at least 2 words separated by a space), act as if there was no namespace. It's not perfect but it's not possible to match author<->galaxy account and there will still be a warning/error issued about it, since the fqrn won't match namespace.role_name. Signed-off-by: Arnaud Patard <[email protected]> * src/ansiblelint/prerun.py: Fix role regexp used to strip prefixes According to : https://galaxy.ansible.com/docs/contributing/creating_role.html#role-metadata: In the past, Galaxy would apply a regex expression to the GitHub repository name and automatically remove 'ansible-' and 'ansible-role-'. For example, if your repository name was 'ansible-role-apache', the role name would translate to 'apache', So update the regexp to handle ansible-role- and ansible- Signed-off-by: Arnaud Patard <[email protected]> * src/ansiblelint/prerun.py: Fix link name when 'role-name' in skip_list If the role-name rule is in skip_list: - if role_name is set in meta/main.yml, assume that the author wants to use this name, even if it's still not up to standards and set the link name to the computed fqrn, - if the role_name is not set, just use the current directory name. Note: don't use 'role_name' variable here since some part of the name has been stripped from the current directory name. Signed-off-by: Arnaud Patard <[email protected]> * src/ansiblelint/prerun.py: split _install_galaxy_role Flake8 is complaining that the function is now too complex, so split it into several ones. Signed-off-by: Arnaud Patard <[email protected]> * src/ansiblelint/prerun.py: Make _get_galaxy_role_* return empty string Instead of using None for value not found and sometime return an empty string make both functions always return a string and make it empty is something went wrong. Signed-off-by: Arnaud Patard <[email protected]> * src/ansiblelint/prerun.py: Revert "Fix role name from SCM" As it may lead to breakages, drop the check on .git or .hg presence to get role name. Signed-off-by: Arnaud Patard <[email protected]> Co-authored-by: Sorin Sbarnea <[email protected]>
- Loading branch information