Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/ansiblelint/rules/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class GalaxyRule(AnsibleLintRule):
"galaxy[version-missing]": "galaxy.yaml should have version tag.",
"galaxy[no-runtime]": "meta/runtime.yml file not found.",
"galaxy[invalid-dependency-version]": "Invalid collection metadata. Dependency version spec range is invalid",
"galaxy[no-repository]": "galaxy.yaml should have a repository key for publication to Galaxy. See https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html",
"galaxy[no-license]": "galaxy.yaml should have a license or license_file key for publication to Galaxy. See https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html",
}

def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
Expand Down Expand Up @@ -179,6 +181,26 @@ def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
),
)

# Check for repository key - recommended for Galaxy publication
if "repository" not in data:
results.append(
self.create_matcherror(
message="galaxy.yaml should have a repository key for publication to Galaxy. See https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html",
tag="galaxy[no-repository]",
filename=file,
),
)

# Check for license or license_file key - recommended for Galaxy publication
if "license" not in data and "license_file" not in data:
results.append(
self.create_matcherror(
message="galaxy.yaml should have a license or license_file key for publication to Galaxy. See https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html",
tag="galaxy[no-license]",
filename=file,
),
)

return results


Expand Down
3 changes: 1 addition & 2 deletions src/ansiblelint/schemas/galaxy.json
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,7 @@
"version",
"readme",
"authors",
"description",
"repository"
"description"
],
"title": "Ansible galaxy.yml Schema",
"type": "object"
Expand Down
Loading