diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
commit | 975f66f2eebe9dadba04f275774d4ab83f74cf25 (patch) | |
tree | 89bd26a93aaae6a25749145b7e4bca4a1e75b2be /ansible_collections/sensu/sensu_go/tests/sanity | |
parent | Initial commit. (diff) | |
download | ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.tar.xz ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.zip |
Adding upstream version 7.7.0+dfsg.upstream/7.7.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/sensu/sensu_go/tests/sanity')
8 files changed, 89 insertions, 0 deletions
diff --git a/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.10.txt b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.10.txt new file mode 100644 index 000000000..af9fcfb5e --- /dev/null +++ b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.10.txt @@ -0,0 +1,4 @@ +plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module +tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call +tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints +tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints diff --git a/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.11.txt b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.11.txt new file mode 100644 index 000000000..af9fcfb5e --- /dev/null +++ b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.11.txt @@ -0,0 +1,4 @@ +plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module +tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call +tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints +tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints diff --git a/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.12.txt b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.12.txt new file mode 100644 index 000000000..af9fcfb5e --- /dev/null +++ b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.12.txt @@ -0,0 +1,4 @@ +plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module +tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call +tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints +tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints diff --git a/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.13.txt b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.13.txt new file mode 100644 index 000000000..af9fcfb5e --- /dev/null +++ b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.13.txt @@ -0,0 +1,4 @@ +plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module +tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call +tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints +tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints diff --git a/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.14.txt b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.14.txt new file mode 100644 index 000000000..af9fcfb5e --- /dev/null +++ b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.14.txt @@ -0,0 +1,4 @@ +plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module +tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call +tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints +tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints diff --git a/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.15.txt b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.15.txt new file mode 100644 index 000000000..af9fcfb5e --- /dev/null +++ b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.15.txt @@ -0,0 +1,4 @@ +plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module +tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call +tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints +tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints diff --git a/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.9.txt b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.9.txt new file mode 100644 index 000000000..5a7ce7659 --- /dev/null +++ b/ansible_collections/sensu/sensu_go/tests/sanity/ignore-2.9.txt @@ -0,0 +1,3 @@ +plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module +tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints +tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints diff --git a/ansible_collections/sensu/sensu_go/tests/sanity/validate-role-metadata.py b/ansible_collections/sensu/sensu_go/tests/sanity/validate-role-metadata.py new file mode 100755 index 000000000..b8544ff9e --- /dev/null +++ b/ansible_collections/sensu/sensu_go/tests/sanity/validate-role-metadata.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +import argparse +import json +import os +import sys + +import yaml + +import urllib.request + + +def _get_arg_parser(): + parser = argparse.ArgumentParser(description="Validate role metadata") + parser.add_argument("role", nargs="+", help="role path") + return parser + + +def _validate_role_platforms(platforms): + base_url = "https://galaxy.ansible.com/api/v1/platforms/?name={0}&release={1}" + msgs = [] + for platform in platforms: + for release in platform["versions"]: + url = base_url.format(platform["name"], release) + f = urllib.request.urlopen(url) + + if len(json.loads(f.read().decode('utf-8'))["results"]) != 1: + msgs.append(("ERROR", "Invalid platform '{0} {1}'".format( + platform["name"], release, + ))) + + return msgs + + +def _validate_role(role_path): + meta_file = os.path.join(role_path, "meta", "main.yml") + with open(meta_file) as fd: + galaxy_info = yaml.safe_load(fd)["galaxy_info"] + + msgs = [] + msgs.extend(_validate_role_platforms(galaxy_info["platforms"])) + + return msgs + + +def main(): + args = _get_arg_parser().parse_args() + no_msgs = 0 + for role in args.role: + msgs = _validate_role(role) + for msg in msgs: + no_msgs += 1 + print("{0}: {1}".format(*msg)) + + return 0 if no_msgs == 0 else 1 + + +if __name__ == "__main__": + sys.exit(main()) |