From 75407d3e439653ef4b103c383d653df32b081821 Mon Sep 17 00:00:00 2001 From: John R Barker Date: Wed, 21 Nov 2018 17:29:29 +0000 Subject: [PATCH] Validate DOCUMENTATION.author (#48993) * Validate DOCUMENTATION.author Ensure that author line includes a GitHub account --- .../cloud/openstack/os_keystone_domain.py | 2 +- .../cyberark/cyberark_authentication.py | 5 +++- .../identity/cyberark/cyberark_user.py | 5 +++- lib/ansible/modules/monitoring/pagerduty.py | 2 +- lib/ansible/modules/monitoring/pingdom.py | 2 +- .../modules/monitoring/zabbix/zabbix_group.py | 2 +- .../modules/monitoring/zabbix/zabbix_host.py | 2 +- .../monitoring/zabbix/zabbix_hostmacro.py | 2 +- .../monitoring/zabbix/zabbix_screen.py | 2 +- .../network/cloudengine/ce_ospf_vrf.py | 2 +- .../modules/network/panos/panos_sag.py | 2 +- .../modules/packaging/language/yarn.py | 2 +- lib/ansible/modules/system/cron.py | 2 +- lib/ansible/modules/system/setup.py | 2 +- test/sanity/validate-modules/schema.py | 25 +++++++++++++++++-- 15 files changed, 43 insertions(+), 16 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_keystone_domain.py b/lib/ansible/modules/cloud/openstack/os_keystone_domain.py index c3685aa09ef..29f931ac41d 100644 --- a/lib/ansible/modules/cloud/openstack/os_keystone_domain.py +++ b/lib/ansible/modules/cloud/openstack/os_keystone_domain.py @@ -17,7 +17,7 @@ module: os_keystone_domain short_description: Manage OpenStack Identity Domains author: - Monty Taylor (@emonty) - - Haneef Ali + - Haneef Ali (@haneefs) extends_documentation_fragment: openstack version_added: "2.1" description: diff --git a/lib/ansible/modules/identity/cyberark/cyberark_authentication.py b/lib/ansible/modules/identity/cyberark/cyberark_authentication.py index ef72ae4e2e4..60257fc2fdf 100644 --- a/lib/ansible/modules/identity/cyberark/cyberark_authentication.py +++ b/lib/ansible/modules/identity/cyberark/cyberark_authentication.py @@ -13,7 +13,10 @@ DOCUMENTATION = ''' --- module: cyberark_authentication short_description: Module for CyberArk Vault Authentication using PAS Web Services SDK -author: Edward Nunez @ CyberArk BizDev (@enunez-cyberark, @cyberark-bizdev, @erasmix) +author: + - Edward Nunez (@enunez-cyberark) CyberArk BizDev + - Cyberark Bizdev (@cyberark-bizdev) + - erasmix (@erasmix) version_added: 2.4 description: - Authenticates to CyberArk Vault using Privileged Account Security Web Services SDK and diff --git a/lib/ansible/modules/identity/cyberark/cyberark_user.py b/lib/ansible/modules/identity/cyberark/cyberark_user.py index b10bb290db2..966ea08700f 100644 --- a/lib/ansible/modules/identity/cyberark/cyberark_user.py +++ b/lib/ansible/modules/identity/cyberark/cyberark_user.py @@ -13,7 +13,10 @@ DOCUMENTATION = ''' --- module: cyberark_user short_description: Module for CyberArk User Management using PAS Web Services SDK -author: Edward Nunez @ CyberArk BizDev (@enunez-cyberark, @cyberark-bizdev, @erasmix) +author: + - Edward Nunez (@enunez-cyberark) CyberArk BizDev + - Cyberark Bizdev (@cyberark-bizdev) + - erasmix (@erasmix) version_added: 2.4 description: - CyberArk User Management using PAS Web Services SDK. It currently supports the following diff --git a/lib/ansible/modules/monitoring/pagerduty.py b/lib/ansible/modules/monitoring/pagerduty.py index 8a7c07acf05..81f3e7216c3 100644 --- a/lib/ansible/modules/monitoring/pagerduty.py +++ b/lib/ansible/modules/monitoring/pagerduty.py @@ -23,7 +23,7 @@ version_added: "1.2" author: - "Andrew Newdigate (@suprememoocow)" - "Dylan Silva (@thaumos)" - - "Justin Johns" + - "Justin Johns (!UNKNOWN)" - "Bruce Pennypacker (@bpennypacker)" requirements: - PagerDuty API access diff --git a/lib/ansible/modules/monitoring/pingdom.py b/lib/ansible/modules/monitoring/pingdom.py index 7ebad7043e6..8e8252fd499 100644 --- a/lib/ansible/modules/monitoring/pingdom.py +++ b/lib/ansible/modules/monitoring/pingdom.py @@ -21,7 +21,7 @@ description: version_added: "1.2" author: - "Dylan Silva (@thaumos)" - - "Justin Johns" + - "Justin Johns (!UNKNOWN)" requirements: - "This pingdom python library: https://github.com/mbabineau/pingdom-python" options: diff --git a/lib/ansible/modules/monitoring/zabbix/zabbix_group.py b/lib/ansible/modules/monitoring/zabbix/zabbix_group.py index 0f09a660e45..b2ba73d0b91 100644 --- a/lib/ansible/modules/monitoring/zabbix/zabbix_group.py +++ b/lib/ansible/modules/monitoring/zabbix/zabbix_group.py @@ -23,7 +23,7 @@ description: version_added: "1.8" author: - "Cove (@cove)" - - "Tony Minfei Ding" + - "Tony Minfei Ding (!UNKNOWN)" - "Harrison Gu (@harrisongu)" requirements: - "python >= 2.6" diff --git a/lib/ansible/modules/monitoring/zabbix/zabbix_host.py b/lib/ansible/modules/monitoring/zabbix/zabbix_host.py index 67d905521fb..6028faeb611 100644 --- a/lib/ansible/modules/monitoring/zabbix/zabbix_host.py +++ b/lib/ansible/modules/monitoring/zabbix/zabbix_host.py @@ -22,7 +22,7 @@ description: version_added: "2.0" author: - "Cove (@cove)" - - Tony Minfei Ding + - Tony Minfei Ding (!UNKNOWN) - Harrison Gu (@harrisongu) - Werner Dijkerman (@dj-wasabi) - Eike Frost (@eikef) diff --git a/lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py b/lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py index afaa5a631e3..a93ed1c4864 100644 --- a/lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py +++ b/lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py @@ -22,7 +22,7 @@ description: version_added: "2.0" author: - "Cove (@cove)" - - Dean Hailin Song + - Dean Hailin Song (!UNKNOWN) requirements: - "python >= 2.6" - zabbix-api diff --git a/lib/ansible/modules/monitoring/zabbix/zabbix_screen.py b/lib/ansible/modules/monitoring/zabbix/zabbix_screen.py index 98df31f5539..dc3e406f827 100644 --- a/lib/ansible/modules/monitoring/zabbix/zabbix_screen.py +++ b/lib/ansible/modules/monitoring/zabbix/zabbix_screen.py @@ -22,7 +22,7 @@ description: version_added: "2.0" author: - "Cove (@cove)" - - "Tony Minfei Ding" + - "Tony Minfei Ding (!UNKNOWN)" - "Harrison Gu (@harrisongu)" requirements: - "python >= 2.6" diff --git a/lib/ansible/modules/network/cloudengine/ce_ospf_vrf.py b/lib/ansible/modules/network/cloudengine/ce_ospf_vrf.py index dc27e9a59e3..b262ce02488 100644 --- a/lib/ansible/modules/network/cloudengine/ce_ospf_vrf.py +++ b/lib/ansible/modules/network/cloudengine/ce_ospf_vrf.py @@ -27,7 +27,7 @@ version_added: "2.4" short_description: Manages configuration of an OSPF VPN instance on HUAWEI CloudEngine switches. description: - Manages configuration of an OSPF VPN instance on HUAWEI CloudEngine switches. -author: Yang yang (@CloudEngine Ansible) +author: Yang yang (@QijunPan) options: ospf: description: diff --git a/lib/ansible/modules/network/panos/panos_sag.py b/lib/ansible/modules/network/panos/panos_sag.py index 2abbcf06204..d22e85e28c0 100644 --- a/lib/ansible/modules/network/panos/panos_sag.py +++ b/lib/ansible/modules/network/panos/panos_sag.py @@ -25,7 +25,7 @@ module: panos_sag short_description: Create a static address group. description: - Create a static address group object in the firewall used for policy rules. -author: "Vinay Venkataraghavan @vinayvenkat" +author: "Vinay Venkataraghavan (@vinayvenkat)" version_added: "2.4" requirements: - pan-python can be obtained from PyPI U(https://pypi.org/project/pan-python/) diff --git a/lib/ansible/modules/packaging/language/yarn.py b/lib/ansible/modules/packaging/language/yarn.py index 6a4ecba471e..f5bc45b3d75 100644 --- a/lib/ansible/modules/packaging/language/yarn.py +++ b/lib/ansible/modules/packaging/language/yarn.py @@ -23,7 +23,7 @@ description: version_added: "2.6" author: - "David Gunter (@verkaufer)" - - "Chris Hoffman (@chrishoffman, creator of NPM Ansible module)" + - "Chris Hoffman (@chrishoffman), creator of NPM Ansible module)" options: name: description: diff --git a/lib/ansible/modules/system/cron.py b/lib/ansible/modules/system/cron.py index 8fa1d516343..e7d3fc9b3d2 100644 --- a/lib/ansible/modules/system/cron.py +++ b/lib/ansible/modules/system/cron.py @@ -128,7 +128,7 @@ requirements: - cron author: - Dane Summers (@dsummersl) - - Mike Grozak + - Mike Grozak (@rhaido) - Patrick Callahan (@dirtyharrycallahan) - Evan Kaufman (@EvanK) - Luca Berruti (@lberruti) diff --git a/lib/ansible/modules/system/setup.py b/lib/ansible/modules/system/setup.py index aa2f9cacb84..5654b10cfa5 100644 --- a/lib/ansible/modules/system/setup.py +++ b/lib/ansible/modules/system/setup.py @@ -83,7 +83,7 @@ notes: author: - "Ansible Core Team" - "Michael DeHaan" - - "David O'Brien @david_obrien davidobrien1985" + - "David O'Brien (@davidobrien1985)" ''' EXAMPLES = """ diff --git a/test/sanity/validate-modules/schema.py b/test/sanity/validate-modules/schema.py index 71d95f1f00a..0c98b679a31 100644 --- a/test/sanity/validate-modules/schema.py +++ b/test/sanity/validate-modules/schema.py @@ -16,11 +16,21 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from voluptuous import ALLOW_EXTRA, PREVENT_EXTRA, All, Any, Length, Required, Schema, Self +import re +from voluptuous import ALLOW_EXTRA, PREVENT_EXTRA, All, Any, Length, Invalid, Required, Schema, Self from ansible.module_utils.six import string_types +from ansible.module_utils.common.collections import is_iterable list_string_types = list(string_types) any_string_types = Any(*string_types) +# Valid DOCUMENTATION.author lines +# Based on Ansibulbot's extract_github_id() +# author: First Last (@name) [optional anything] +# "Ansible Core Team" - Used by the Bot +# "Michael DeHaan" - nop +# "Name (!UNKNOWN)" - For the few untraceable authors +author_line = re.compile(r'^\w.*(\(@([\w-]+)\)|!UNKNOWN)(?![\w.])|^Ansible Core Team$|^Michael DeHaan$') + def sequence_of_sequences(min=None, max=None): return All( @@ -140,6 +150,17 @@ deprecation_schema = Schema( ) +def author(value): + + if not is_iterable(value): + value = [value] + + for line in value: + m = author_line.search(line) + if not m: + raise Invalid("Invalid author") + + def doc_schema(module_name): deprecated_module = False @@ -151,7 +172,7 @@ def doc_schema(module_name): Required('short_description'): Any(*string_types), Required('description'): Any(list_string_types, *string_types), Required('version_added'): Any(float, *string_types), - Required('author'): Any(None, list_string_types, *string_types), + Required('author'): All(Any(None, list_string_types, *string_types), author), 'notes': Any(None, list_string_types), 'requirements': list_string_types, 'todo': Any(None, list_string_types, *string_types),