You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/hacking
Matt Martz 56d142350d
Add support for importlib.resources (#78915)
* Add support for importlib.resources

* Remove the importlib.resources imports

* return the correct data

* Some code comments, and re-order for consistency

* Disallow traversing packages below an individual collection

* Add a traversable class for namespaces

* Re-use variable

* Utilize itertools.chain.from_iterable

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>

* Simplify logic to check for packages from ansible loaders

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>

* Just a generator expression, instead of a generator

* docstrings

* Add comment about find_spec for our namespaces

* Add some initial unit tests for importlib.resources

* normalize

* Utilize importlib.resources for listing collections

* collections_path is already in config, just use config

* install uses a different default for collections_path

* Remove unused import

* Remove duplicate __truediv__

* Bring back TraversableResources

* Apply some small suggestions from code review

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Matt Davis <6775756+nitzmahone@users.noreply.github.com>

* Remove cross contamination between plugin loader code and CLI code

* Remove unused import

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Matt Davis <6775756+nitzmahone@users.noreply.github.com>
1 year ago
..
azp Allow result sha to be overriden with local sha (#77832) 2 years ago
backport Add a script for adding backport references 4 years ago
build_library stable docs build: do not use YAML parsing/serialization for .deps files (#79233) 2 years ago
tests Fix distro fact handling for Flatcar (#77635) 2 years ago
ticket_stubs Cleanup of cannned responses (#76689) 2 years ago
README.md Update README.md (#78139) 2 years ago
ansible-profile Rename python files in hacking/ directory to have .py suffix 5 years ago
build-ansible.py Update default containers to 3.4.0. (#74415) 3 years ago
create_deprecation_bug_reports.py Add script to handle more deprecations. (#77400) 2 years ago
deprecated_issue_template.md Fix deprecated issue creator (#55327) 5 years ago
env-setup Make "~/.ansible" path configurable (#76114) 2 years ago
env-setup.fish Honor `--quiet` parameter properly in fish shell (#77180) 2 years ago
fix_test_syntax.py More boilerplate fixes. (#70224) 4 years ago
get_library.py More boilerplate fixes. (#70224) 4 years ago
report.py More boilerplate fixes. (#70224) 4 years ago
return_skeleton_generator.py Add missing space after keywords. (#78480) 2 years ago
test-module Rename python files in hacking/ directory to have .py suffix 5 years ago
test-module.py Add support for importlib.resources (#78915) 1 year ago
update-sanity-requirements.py ansible-test - Update import test and sanity requirements. (#76308) 3 years ago

README.md

'Hacking' directory tools

env-setup

The 'env-setup' script modifies your environment to allow you to run ansible from a git checkout using python >= 3.8.

First, set up your environment to run from the checkout:

$ source ./hacking/env-setup

You will need some basic prerequisites installed. If you do not already have them and do not wish to install them from your operating system package manager, you can install them from pip

$ easy_install pip               # if pip is not already available
$ pip install -r requirements.txt

From there, follow ansible instructions on docs.ansible.com as normal.

test-module.py

'test-module.py' is a simple program that allows module developers (or testers) to run a module outside of the ansible program, locally, on the current machine.

Example:

$ ./hacking/test-module.py -m lib/ansible/modules/command.py -a "echo hi"

This is a good way to insert a breakpoint into a module, for instance.

For more complex arguments such as the following yaml:

parent:
  child:
    - item: first
      val: foo
    - item: second
      val: boo

Use:

$ ./hacking/test-module.py -m module \
    -a '{"parent": {"child": [{"item": "first", "val": "foo"}, {"item": "second", "val": "bar"}]}}'

return_skeleton_generator.py

return_skeleton_generator.py helps in generating the RETURNS section of a module. It takes JSON output of a module provided either as a file argument or via stdin.

fix_test_syntax.py

A script to assist in the conversion for tests using filter syntax to proper jinja test syntax. This script has been used to convert all of the Ansible integration tests to the correct format for the 2.5 release. There are a few limitations documented, and all changes made by this script should be evaluated for correctness before executing the modified playbooks.