Commit graph

52 commits

Author SHA1 Message Date
Matt Clay 5dfc7ee078 Remove Shippable CI provider from ansible-test. 2021-05-05 17:42:13 -07:00
Matt Clay a30c55f68a Remove deprecated common.removed module_util.
Tests have been updated to reflect its removal as well.
2021-04-29 16:07:56 -07:00
Matt Clay 8223dfccbe ansible-test - Improve __main__ checks. 2021-04-27 09:00:26 -07:00
Paul Arthur 7b5dad2321 validate-modules: don't error on valid Ansible YAML in EXAMPLES 2021-04-22 12:42:47 -07:00
Brian Coca 0a7670d1f7
deprecated include (#71262)
* deprecated include

  Update lib/ansible/modules/_include.py
  updated version numbers in schema check (real fix in separate PR)

Co-authored-by: flowerysong <junk+github@flowerysong.com>
Co-authored-by: Matt Clay <matt@mystile.com>
2021-04-15 14:19:04 -04:00
Baptiste Mille-Mathias 3e63eb8418 fix typo 2021-03-18 12:50:06 -07:00
Paul Belanger 9ec4e08534
Don't match passive_interface for validate-modules (#73880)
This is a follow up to:

  https://github.com/ansible/ansible/pull/73508

To avoid adding no_log statements to passive_interface args.

Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2021-03-13 08:28:57 -06:00
Felix Fontein 7c0af58449
validate-modules no_log test: extend search range, add more known false-positives (#73882)
* validate-modules no_log test: extend search range, add more known false-positives.

* Mark false-positives.
2021-03-13 08:28:33 -06:00
Felix Fontein b2015c98e2
validate-modules: make sure that options that potentially contain secret data have no_log set (#73508)
* Catch more potential errors (and increase false-positive rate).
* Flag some false-positives in lib/ansible/modules/ with no_log=False.

Co-authored-by: John Barker <john@johnrbarker.com>
2021-03-11 12:57:11 -05:00
Gonéri Le Bouder 7cf80f50d1
validate_modules: fails with .id attribute not found (#73322)
* validate_modules: fails with .id attribute not found

This patch addresses a problem in the `found_try_except_import` test.

This module tries to identify lines like:

`HAS_FOO = True`

In this case, the target (`HAS_FOO`) is of type `ast.Name` and has a
`id` attribute which provide the name.

In my case, I've a line that set a module attribute`. In this case, the
target (`module.var`) has the type `ast.Attribute` and no `id`
attribute. The code trigger an `AttributeError` exception.

This patch ensures we compare a `ast.Name`.

* Update test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/main.py
2021-02-02 13:29:36 -08:00
Matt Clay 13d08d232c Rename ansible-test functions to match constants. 2021-01-26 14:24:16 -08:00
Sam Doooran 5ecfb19cad
arg_spec - move validator lookup method to a function (#72667)
* arg_spec - move type checking lookup method to a function

* Change get_wanted_type name and behavior

Change the name to get_validator to bette describe what it is doing.

Change the interface to always return a value. This lines up with the behavior of get_*
functions always returning something or None and check_* functions raising an
Exception if something went wrong during the check.

* Add param to check_type_str()

Not meant to be a long term fix, but gets tests passing. More work is needed to figure
out how to solve this cleanly.

* Remove private attribute mapping types to validator

Since the function that needs it has moved to parameters.py, there is no need to have it as
a attribute of AnsibleModule.

Update tests that were referencing the private attribute.

* Use private method for 'str' type

To avoid having to put the string conversion warning behavior in the check_type_str() method,
use the private _check_type_str() method for 'str' type.

Import CHECK_ARGUMENT_TYPES_DISPATCHER for backwards compalitibility and store it as
a private attribute.

Revert changes to support plugins that are referencing serf._CHECK_ARGUMENT_TYPES_DISPATCHER.

* Add changelog

* Change function name to better reflect its... function

* Change dict name to better reflect its contents

CHECK_ARGUMENT_TYPES_DISPATCHER --> DEFAULT_TYPE_VALIDATORS

* Fix changelog
2020-12-17 17:15:00 -05:00
Felix Fontein 5226ac5778
The implicit default for type=bool options is not 'false', but 'none' (#72699)
* The implicit default for type=bool options is not 'false', but 'none'.

* Fix modules, resp. add ignore.txt entries.
2020-12-04 12:13:14 -05:00
Brian Coca 4b673484f0
rethink wording (#70028)
* rethink wording
* removed unrequired requirement
* fix tests
* fixed versions
Co-authored-by: Sloane Hertel <shertel@redhat.com>
2020-10-30 17:13:12 -04:00
Felix Fontein 7e2cc7db12
validate-modules: fix version_added validation for top-level, fix error codes (#70869)
* Also validate top-level version_added.

* Fix error code.

* Produce same version_added validation error in schema than in code (and stop returning it twice).

* Return correct error codes for invalid version_added for options and return values.

* Add changelog.

* Fix forgotten closing braket.

* Accept 'historical' for some top-level version_added.
2020-07-28 10:10:35 -05:00
Abhijeet Kasurde c1402ddee0
validate_modules: added missing single quote (#70744)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-07-20 09:26:17 -05:00
Jordan Borean 40ce448657
ansible-test - do not validate blacklisted ps modules (#70376)
* ansible-test - do not validate blacklisted ps modules

* Update changelogs/fragments/validate-modules-ps-doc-blacklist.yaml

Co-authored-by: Matt Clay <matt@mystile.com>

Co-authored-by: Matt Clay <matt@mystile.com>
2020-07-01 07:59:53 +10:00
Felix Fontein 80410f292b Fix missing allow_date=False. 2020-06-15 11:18:51 -07:00
Felix Fontein 0617514176
Boolean error: fix deprecation date sanity check. (#70047) 2020-06-13 09:05:40 -04:00
Felix Fontein 2fa65eb5e1
validate-modules: allow YAML dates in module documentation and meta/runtime.yml. (#70025) 2020-06-12 15:36:38 +01:00
James Cassell 47d14a33bd
config: singular ANSIBLE_COLLECTIONS_PATH (#70007)
* config: singular ANSIBLE_COLLECTIONS_PATH

Every other *_PATH setting in ansible is singular, and the traditional
$PATH variable is also singular despite containing a list of
directories.  Let's be consistent both internally and with POSIX
tradition.

* update all ANSIBLE_COLLECTIONS_PATHS env references to be singular

* deprecate plural ANSIBLE_COLLECTIONS_PATHS setting
2020-06-11 11:40:13 -07:00
Felix Fontein f1ab7cf0c6
Validate-modules: adjust test to fixes in #69977 (#69978) 2020-06-10 18:02:01 +10:00
Felix Fontein a862ff2d43
Deprecation revisited (#69926)
* Allow to specify collection_name separately for deprecation.

* Use new functionality in Ansible.

* Use new functionality in tests.

* Update tagging/untagging functions.

* Update pylint deprecated sanity test.

* Update validate-modules. Missing are basic checks for version_added (validate semantic version format for collections).

* Improve version validation. Re-add version_added validation.

* Make sure collection names are added to return docs before schema validation.

* Extra checks to avoid crashes on bad data.

* Make C# module utils code work, and update/extend tests.

* Add changelog fragment.

* Stop extracting collection name from potentially tagged versions/dates.

* Simplify C# code.

* Update Windows modules docs.

* Forgot semicolons.
2020-06-09 15:21:19 -07:00
Felix Fontein 3e566768c1 Fix broken validate-modules. 2020-06-06 11:00:10 -07:00
Brian Coca 062e780a68
starting metadata sunset (#69454)
* starting metadata sunset

 - purged metadata from any requirements
 - fix indent in generic handler for yaml content (whey metadata display was off)
 - make more resilient against bad formed docs
 - removed all metadata from docs template
 - remove metadata from schemas
 - removed mdata tests and from unrelated tests

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Rick Elrod <rick@elrod.me>
2020-06-04 21:01:46 -04:00
Felix Fontein 2dbd5dc2ae
ansible-test: do not accept empty string as valid version number (#69816)
* Work around strange behavior of StrictVersion and SemanticVersion constructors that they accept an falsy value.

* Do not accept empty strings as versions.
2020-06-04 13:25:05 -07:00
Felix Fontein 4794b98f2a
Fix version_added test (#69756)
* Fix version_added test for changes in #69680.

* Fix error message.
2020-05-29 08:25:14 -07:00
Felix Fontein 40f21dfd3c
Version source tagging (automatic and manual) for version_added and deprecation versions (#69680)
* Track collection for version_added.
Validate *all* version numbers in validate-modules.
For tagged version numbers (i.e. version_added), consider source collection to chose validation.

* Make tagging/untagging functions more flexible.

* Tag all versions in doc fragments.

* Tag all deprecation versions issued by code.

* Make Display.deprecated() understand tagged versions.

* Extend validation to enforce tagged version numbers.

* Tag versions in tests.

* Lint and fix test.

* Mention collection name in collection loader's deprecation/removal messages.

* Fix error IDs.

* Handle tagged dates in Display.deprecated().

* Also require that removed_at_date and deprecated_aliases.date are tagged.

* Also automatically tag/untag removed_at_date; fix sanity module removal version check.

* Improve error message when invalid version number is used (like '2.14' in collections).
2020-05-28 22:46:16 -07:00
Felix Fontein 31bf3a5622
Deprecate module in collection: allow removal date in documentation, make validate-modules ensure version and date match (#69727)
* Allow to deprecate module by date in documentation.

* Make sure deprecation date/version match between module docs and meta/runtime.yml.

* Unrelated fix: don't compare deprecated module version to Ansible's version in collection.

* Allow documentation's removal version to be something else than fixed list of Ansible versions for collections.

* Linting.

* Allow to deprecate plugin options by date.

* Add changelog fragment for deprecation by date (also covers #68177).
2020-05-28 14:20:52 -07:00
Felix Fontein ea04e0048d
Allow to deprecate options and aliases by date (#68177)
* Allow to deprecate options and aliases by date instead of only by version.

* Update display.deprecate().

* Adjust behavior to conform to tested behavior, extend tests, and improve C# style.

* Parse date and fail on invalid date.

This is mainly to make sure that people start using invalid dates, and we eventually have a mess to clean up.

* C# code: improve validation and update/extend tests.

* Make sure that deprecate() is not called with both date and version.

* Forgot to remove no longer necessary formatting.

* Adjust order of warnings in C# code.

* Adjust unrelated test.

* Fix grammar (and make that test pass).

* Don't parse date, and adjust message to be same as in #67684.

* Sanity tests: disable date in past test.

* Validate-modules: validate ISO 8601 date format.

* Validate-modules: switch schema declaration for deprecated_aliases to improve error messages for invalid dates.

* Use DateTime instead of string for date deprecation.

* Validate that date in deprecated_aliases is actually a DateTime.

* Fix tests.

* Fix rebasing error.

* Adjust error codes for pylint, and add removed_at_date and deprecated_aliases.date checks to validate-modules.

* Make deprecation date in the past error codes optional.

* Make sure not both version and date are specified for AnsibleModule.deprecate() calls.

* Stop using Python 3.7+ API.

* Make sure errors are actually reported. Re-add 'ansible-' prefix.

* Avoid crashing when 'name' isn't there.

* Linting.

* Update lib/ansible/module_utils/csharp/Ansible.Basic.cs

Co-authored-by: Jordan Borean <jborean93@gmail.com>

* Adjust test to latest change.

* Prefer date over version if both end up in Display.deprecated().

Co-authored-by: Jordan Borean <jborean93@gmail.com>
2020-05-26 20:23:56 -04:00
Matt Davis f7dfa817ae
collection routing (#67684)
* `meta/` directory in collections
* runtime metadata for redirection/deprecation/removal of plugin loads
* a compatibility layer to keep existing content working on ansible-base + collections
* a Python import redirection layer to keep collections-hosted (and otherwise moved) content importable by things that don't know better
* supported Ansible version validation on collection loads
2020-05-26 09:42:06 -07:00
Felix Fontein 0e15375ffe
Add deprecated removed_in_version and deprecated_aliases version tests (#66920) 2020-05-13 13:58:09 -07:00
John R Barker 084587913a
validate-modules: deprecated modules in collections (#68646)
* validate-modules: deprecated modules in collections

In Collections a module is marked as deprecated via meta/routing.yml

Use this file, rather than the leading `_` as part of the deprecated
test.

* Correct variable

* review comments

* indentation

* Read routing.yml only once

* pep8

* Apply suggestions from code review

Co-authored-by: Matt Clay <matt@mystile.com>

* review: remove duplicated conditional

Co-authored-by: Matt Clay <matt@mystile.com>
2020-05-07 08:11:46 +01:00
Toshio Kuratomi 39b3942048 Remove left hand side slicing
Left hand side slicing is confusing and slower but maybe more memory
efficient in some circumstances.  There is one case where it adds to
code safety: when it's used to substitute a different list in place of a
slice of the original list and the original list could have been bound
to a different variable in some other code.  (The most likely case of
this is when it's a global variable and some other code might import
that variable name).

Because of the confusion factor we think it should only be used for the
safety case or where it's been benchmarked and shown to have some sort
of documentatble improvement.  At the moment, only one piece of code
falls into those categories so this PR removes all the other instances
of left hand side slicing.
2020-05-06 09:56:40 -07:00
Abhijeet Kasurde b6c2056ea2
mongodb_user: fix doc formatting (#67763)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-02-28 09:04:27 +05:30
Felix Fontein 4373863f25
Module validation: sanity check mutually_exclusive, required_if, required_xxx ... (#66961)
* required_if checks should have three or four parts.

* Validate mutually_exclusive, required_together, required_one_of, required_if and required_by.

* Simplify code.

* Improve messages.

* Add changelog.

* Sanity check.

* Update docs.

* Update ignore.txt.

* Don't continue with tests when terms are not strings.

* Remove ignore.txt entry.

* Make sure validate-modules doesn't choke on things already flagged by schema test.

* Check required_if requirements list for strings.
2020-02-19 12:26:42 -05:00
Abhijeet Kasurde b6753b46a9
Replace 'message' in module parameters (#60051)
* 'message' parameter is replaced by 'commit_message' in grafana_dashboard
* 'message' parameter is replaced by 'notification_message' in datadog_monitor

This change is required since 'message' as parameter name is used internally by
Ansible core engine.

Fixes: #39295 #45362 #47132 #59617

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-02-18 13:00:16 +01:00
Felix Fontein f6815040fd
add_file_common_arguments: fix defaults and tpyes, improve sanity checking (#67243)
* Make validate-modules stop ignore FILE_COMMON_ARGUMENTS.

* Add types to FILE_COMMON_ARGUMENTS and update document fragment to match it.

* Update ignore.txt.

* Add changelog.
2020-02-12 01:44:11 -05:00
Mark Chappell 5d4d9d40af
ansible-test - Add 'get' to the list of bad choices for state (#66921)
* ansible-test - Add 'get' to the list of bad choices for state

* Changelog fragment
2020-01-30 22:38:47 +01:00
Mark Chappell 1156962cde
Forbid state=(list|info) in modules via ansible-test sanity check
PR #66898

This change introduces a new sanity check with code
`parameter-state-invalid-choice` in the `ansible-test sanity`
validator. It enforces modules not to support `list` or `info`
as their `state`.

Co-Authored-By: Sviatoslav Sydorenko <webknjaz@redhat.com>
Co-Authored-By: Felix Fontein <felix@fontein.de>
2020-01-29 21:06:36 +01:00
Mark Chappell 35652ca788 Add tests to make sure that the documented 'elements' matches that defined in argument_spec (#66385)
* Add tests to make sure that the documented 'elements' matches that defined in argument_spec

* Mass-add test/sanity/ignore.txt
2020-01-28 12:33:03 -05:00
Mark Chappell 5ff899662d Add sanity test to require elements entry when argument type=list (#66386)
* Require elements entry for lists

* Bulk add initial test/sanity/ignore.txt
2020-01-28 10:23:22 -05:00
Felix Fontein 8cff585891
Schema validation for argument_spec (#65747)
* Start of schema for argument_spec

* Add changelog.

* Remove superfluous import.

* Update ignore.txt

Co-authored-by: Matt Martz <matt@sivel.net>
2020-01-27 17:26:46 +01:00
Sam Doran 92677d43b6 Account for argument spec of None in validate modules sanity test 2020-01-09 15:11:51 -08:00
Felix Fontein 4be8b2134f Sanity checks: make sure that required in argument spec coincides with documentation (#65437)
* Add sanity test for required parameters, update ignore.txt, and add changelog.
2019-12-03 09:15:07 -06:00
Felix Fontein 784e507671 module sanity checks: improve alias handling (#59060)
* add_file_common_args is only of interest on top-level.
* Handle undocumented arguments in one place.
* Update ignore.txt
* Add changelog
2019-11-21 15:33:27 -05:00
Matt Clay e9f8a34dce
Fixes for validate-modules import handling. (#63932)
* Fix validate-modules support for collections.

- Relative imports now work correctly.
- The collection loader is now used.
- Modules are invoked as `__main__`.

* Remove obsolete validate-modules code ignores.

* Handle sys.exit in validate-modules.

* Add check for AnsibleModule initialization.

* Remove `missing-module-utils-import` check.

This check does not support relative imports or collections.

Instead of trying to overhaul the test, we can rely on the `ansible-module-not-initialized` test instead.

* Fix badly named error codes with `c#` in the name.

The `#` conflicts with comments in the sanity test ignore files.

* Add changelog entries.
2019-10-30 09:48:21 -07:00
Matt Martz 03b98f6351 Fix plain format output functionality (#63107) 2019-10-10 15:46:36 -04:00
Evgeni Golov 48a39f5616 typo: missing-subption-docs → missing-suboption-docs (#62180)
updates the name of the test and all ignore.txt entries
2019-09-12 14:51:20 -05:00
Sam Doran 73248bf27d validate-modules - Use error codes instead of numbers (#60711) 2019-08-28 14:12:56 -07:00