Commit Graph

243 Commits (56d142350d62fb674e1c6874b3ace2cf5cb933a7)

Author SHA1 Message Date
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
Maxwell G ab76916b14
galaxy: Add license_file to manifest directives (#79420)
* galaxy: Add license_file to manifest directives

* ag collection build: Test license handling

This adds tests to ensure that
    - REUSE licensing files: .reuse/dep5, LICENSES/*, anyfile.license
    - galaxy.yml license_file
are always included in the manifest.
2 years ago
Wong Hoi Sing Edison b148fd8dd7
ansible-galaxy - support ``resolvelib >= 0.5.3, < 0.10.0`` (#79399)
* Upgrade `resolvelib >= 0.5.3, < 0.10.0`

https://pypi.org/project/resolvelib/0.9.0/ released on 2022-11-17:

  * https://github.com/sarugaku/resolvelib/blob/master/CHANGELOG.rst#090-2022-11-17
  * https://github.com/sarugaku/resolvelib/releases/tag/0.9.0

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
2 years ago
Matt Martz 942bcf6e7a
Add manifest includes for reuse licenses (#79403)
* Add includes for reuse licenses

* Add additional exludes to follow REJECT_EXTS

* clog frag
2 years ago
Matt Martz d925ece764
Allow pip like version syntax for installing collections (#79405) 2 years ago
Sloane Hertel 89d682464b
Fix isinstance check (#79159)
Use GalaxyAPI for isinstance check instead of RoleDistributionServer, since the latter is defined in __main__ sometimes (when running integration tests or ansible-galaxy from source) and importing from ansible.cli.galaxy won't reference the same object.
2 years ago
Sloane Hertel cb2e434dd2
ansible-galaxy install - fix unnecessary api check when installing a role from git repo (#79090)
* delay server api evaluation until a GalaxyRole needs to make an api call for info, list, and install
2 years ago
Abhijeet Kasurde a48c442275
Misc Typo fixes (#79088) 2 years ago
sbettid 8cf7a0d3f0
Fix collection install from source respects symlinks (#78983)
* Fix installation from source transforms symlinks of dirs to empty dirs

* Add test to check symlinks to dirs are respected when installing from source

* Add changelog for collection install from source symlink to dirs issue
2 years ago
Sloane Hertel a02e22e902
Add --offline option to 'ansible-galaxy collection install' (#78678)
* Add --offline option to 'ansible-galaxy collection install' to prevent querying distribution servers

This allows installing/upgrading individual tarfiles to have dependency resolution.
Previously needed to be done manually with --no-deps or else all collections and dependencies needed to be included in the requirements.

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
2 years ago
Sloane Hertel 41b62f7db4
Limit Galaxy API calls during ansible-galaxy dependency resolution (#77468)
* Limit Galaxy API calls during ansible-galaxy collection dependency resolution when possible

Installing a tarfile with a dependency from a Galaxy server (e.g. dependencies: {'ns.coll': '>=1.0.0'}) does not get the available versions of the dependency from the galaxy server if a sufficient version is already installed.

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
2 years ago
Sloane Hertel 5f2bb2ba93
Add the rest of the runtime keys to the example in the default collection skeleton (#78573) 2 years ago
Matt Martz deb54e4c5b
Relax minimal config to enable manifest functionality (#78574)
* Revert "Fix incorrect docs about how to enable manifest functionality (#78572)"

This reverts commit ac1ca40fb3.
2 years ago
Matt Martz d2f8099118
Use MANIFEST.in style directives to build collections (#78422) 2 years ago
Elijah DeLee f9a450551d
add required file to collection skeleton (#77418)
* add required file to collection skeleton

This file is required to be able to upload a collection.

It is present in
https://github.com/ansible-collections/collection_template/blob/main/meta/runtime.yml
but that does not get used by default.

Without this, if you use the "ansible-galaxy collection init" command
and you try and publish that collection without adding this file, you
get the error:

"ERROR! Galaxy import process failed: 'requires_ansible' in
meta/runtime.yml is mandatory, but no meta/runtime.yml found (Code:
UNKNOWN)"

Also updates relevant test and adds a changelog fragment
2 years ago
Matt Clay 09d0df1d87
Fix variable use before definition. (#78500)
* Fix variable use before definition.

* Include mkstemp in exception handler.

Also remove two pointless variable assignments.
2 years ago
Sloane Hertel 05608b20e8
Fix listing collections that are missing the metadata required by build (#76596)
* Rethread pr/70185 through the dependency resolver

Hang optional metadata toggle on the ConcreteArtifactsManager instead of threading it through whole list codepath

Don't error while listing collections if a collection's metadata is missing keys required for building a collection.

Give an informative warning if metadata has been badly formatted.

Co-authored-by: Sam Doran <sdoran@redhat.com>
2 years ago
Sloane Hertel 5728d72cda
Fix KeyError for ansible-galaxy when caching paginated responses from v3 (#78325)
* Fix KeyError for ansible-galaxy when caching paginated responses from v3

* changelog

* generate responses in loop for test

Co-authored-by: Matt Martz <matt@sivel.net>
2 years ago
Brian Coca fa35aa4865
Galaxy server config updates (#77106)
* ansible-galaxy configurable timeouts

  - also fixed issues with precedence,
    so --ignore-certs now overrides config
  - made galaxy_timeout generic setting,
    if set, it becomes default for server configs,
    but now specific servers can override
  - updated tests or added notes (some tests ignore/override precedence)

Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
2 years ago
David Moreau Simard d81a519f25
Remove .travis.yml files from galaxy init skeletons (#75740)
* Remove .travis.yml files from galaxy init skeletons

These files have existed for many years but in light of the recent
circumstances around Travis, we should not include them by default in
the galaxy init skeletons.

* Add breaking_changes changelog fragment with recommendation to use a custom skeleton if the .travis.yml file is still needed.

Co-authored-by: s-hertel <19572925+s-hertel@users.noreply.github.com>
2 years ago
Sloane Hertel db335498d0
ansible-galaxy - ensure variable is defined for any error when getting the ansible-core distribution (#77993) 2 years ago
Sloane Hertel 143e7fb45e
ansible-galaxy - support resolvelib versions >= 0.5.3, < 0.9.0 (#77649)
* ansible-galaxy - support resolvelib versions >= 0.5.3, <= 0.8.1

Test incompatibilities are removed for resolvelib >= 0.6.0

Test against the latest 0.8.x version and fix requirements

* Fix tests - use a venv for testing the range of resolvelib versions

* Update temporary hardcoded fallback for ansible-test

* Update hardcoded upperbound for sanity tests

* Make error check more flexible
2 years ago
Wouter Schoot 711b51fad6
Remove double spaces in errormessage (#77839) 2 years ago
Felix Fontein 6fbc8bd2bc
Fix boolean condition so that ansible-galaxy collection install works when a valid resolvelib is installed. (#77906) 2 years ago
Sloane Hertel 82f3a57bee
Fix ansible-galaxy traceback when unexpected version of resolvelib is installed (#77630)
* Fix traceback when a supported version of resolvelib is not installed

Try to read the supported version range from the package distribution info and fall back to a hardcoded lowerbound/upperbound (>=0.5.3,<0.6.0).

* Add tests for unsupported resolvelib versions

* Resolve remaining import sanity test issues.

Co-authored-by: Matt Clay <matt@mystile.com>
Co-authored-by: Matt Martz <matt@sivel.net>
2 years ago
Sloane Hertel 400475acc0
validate meta/main.yml dependencies and meta/requirements.yml are both lists before concatenating them together (#77821) 2 years ago
Matt Clay cc5ac88c4c Update mypy test. Fix type hints for Python 3.9.
This also bumps the minimum controller version (for mypy only) to Python 3.9.
2 years ago
Brian Coca b439e41a91
expand ansible-doc coverage (#74963)
* Expand ansible-doc to tests/filters and fix existing issues

  enable filter/test docs if in single file or companion yaml
  add docs for several filters/tests plugins
  allow .yml companion for docs for other plugins, must be colocated
  verify plugins are valid (not modules, cannot)
  fix 'per collection' filtering
  limit old style deprecation (_ prefix) to builtin/legacy
  start move to pathlib for saner path handling
  moved some funcitons, kept backwards compat shims with deprecation notice

  Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
  Co-authored-by: Felix Fontein <felix@fontein.de>
  Co-authored-by: Sandra McCann <samccann@redhat.com>
2 years ago
Jack 4d69c09695
ansible-galaxy collection - ensure dependencies are a dict (#77561)
* fix traceback when installing collection with dependencies set to None
2 years ago
htol d7fbde4ea9
Make "~/.ansible" path configurable (#76114)
* replace hardcoded '~/.ansible' to C.ANSIBLE_HOME
* rename previously existing env ANSIBLE_HOME in env-setup script
* modify cache dir monkeypatching in galaxy api unit tests
* update "version_added" to 2.14 for ANSIBLE_HOME
* fix description of collections with proper use of ANSIBLE_HOME

Co-authored-by: htol <github@h-tol.net>
Co-authored-by: stefanwascoding <stefan@syntaxhelden.de>
2 years ago
Sloane Hertel 477c55b0d2
Get git executable for collections in git repos (#77493)
* Fix traceback installing collections from git repos if git is not installed
2 years ago
Sloane Hertel f8ec660e62
[ansible-galaxy] Fix listing collections with null namespace/name/version metadata (#77014)
* Fall back to implicit namespace.name from the path if the metadata is invalid

* Test listing a collection with null namespace/name/version fields in its galaxy.yml
2 years ago
Sloane Hertel 87d52e0ce0
Only require a keyring if collections with signatures will be installed (#77355)
Fixes #77349
2 years ago
Sloane Hertel f96a661ada
ansible-galaxy - add configuration options for more flexible collection signature verification (#77026)
* Add a toggle to control the number of signatures required to verify the authenticity of a collection

* Make the default number of required valid signatures 1

* Add option to make signature verification strict and fail if there are no valid signatures (e.g. "+1")

* Use a regex to validate --required-valid-signature-count

* Add a toggle to limit the gpg status codes that are considered a failure

* Update documentation and changelog

* Add unit and integration tests for the new options

* Fixes #77146

Fix using user-provided signatures when running 'ansible-galaxy collection verify ns.coll --offline'

Add a test for a user-provided signature when running ansible-galaxy collection verify with --offline

Fix displaying overall gpg failure without extra verbosity

Add a test for displaying gpg failure without verbosity

Improve documentation to be more clear that signature verification only currently applies to collections directly sourced from Galaxy servers
2 years ago
Matt Clay f68c66a3ef Remove collections compat from controller code. 2 years ago
Matt Clay 4867ac217b Code cleanup for type hinting issues. 2 years ago
Matt Clay 7c81a652c0 Type hint fixes. 2 years ago
Matt Clay 0c4c18bc04 Type hint fixes. 2 years ago
Matt Clay 8b2e628565 galaxy - Clean up type hints and imports. 2 years ago
Matt Clay 871b2ca73a Simplify existing type hints. 2 years ago
Matt Clay d31730d781
Fixes for type hinting issues. (#77170) 2 years ago
Sloane Hertel 7657caa072
Fix 'ansible-galaxy collection verify' to display new files/dirs (#76690)
* Fix 'ansible-galaxy collection verify' to report files/directories not listed in the FILES.json

* changelog

* Fix bug in 2.13+
2 years ago
Matt Clay 43c2c983cc Fix type hints in galaxy. 2 years ago
Elijah DeLee 3f924b59f2
use same timeout for galaxy api interactions (#77088)
Also, bump the default. A number of people have reported problems with
this 20 second timeout for a couple of years on
https://github.com/ansible/galaxy/issues/2302

It is mentioned in the issue that resolving dns can sometimes take up to
30 seconds, and that this timeout includes dns resolution.

Includes a changelog message
2 years ago
Sloane Hertel 43e55db208
ansible-galaxy - add signature verification of the MANIFEST.json (#76681)
* ansible-galaxy collection install|verify:

  - Support verifying the origin of the MANIFEST.json when the Galaxy server has provided signatures.
  - Allow supplemental signatures to use during verification on the CLI/requirements file.

* ansible-galaxy collection install:

  - Support disabling signature verification. This silences the warning provided by ansible-galaxy if the Galaxy server provided signatures it cannot use because no keyring is configured.
  - Store Galaxy server metadata alongside installed collections for provenance. This is used by 'ansible-galaxy collection verify --offline'.

* Add unit tests for method that gets signatures from a Galaxy server

* Add integration tests for user-provided signature sources

- Test CLI option combinations
- Test installing collections with valid/invalid signature sources
- Test disabling GPG verification when installing collections
- Test verifying collections with valid/invalid signature sources

* Make signature verification advisory-by-default if signatures are provided by the Galaxy server

- Make the default keyring None
- Warn if the keyring is None but the Galaxy server provided signatures
- Error if the keyring is None but the user supplied signatures
- Error if the keyring is not None but is invalid

* changelog

* add ansible-galaxy user documentation for new options

Co-authored-by: Matt Martz <matt@sivel.net>
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Martin Krizek <martin.krizek@gmail.com>
Co-authored-by: Sandra McCann <samccann@redhat.com>
Co-authored-by: Andy Mott <amott@redhat.com>
Co-authored-by: John R Barker <john@johnrbarker.com>
2 years ago
Adrian Likins 20cc87f059
Expect upper case message 'levels' for galaxy publish results (#63530) 2 years ago
Sloane Hertel 15ace5a854
ansible-galaxy - validate version for directories and collections in git repos (#76579)
* Ensure the version is valid for directories and collections in git repos before installing

Fix the error message for invalid semantic versions

* Make requested changes

* Add a test case for unhandled ValueError exception

* Add changelog

* Update lib/ansible/galaxy/collection/galaxy_api_proxy.py

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

* Reword error message

Include link to learn how to compose a semver version

* Move version validation into the caller, find_matches

* Add tests for more invalid version types

* Remove unused import

Fix raising unexpected error

* Update lib/ansible/galaxy/collection/__init__.py

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

* Update lib/ansible/galaxy/dependency_resolution/providers.py

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

* Update lib/ansible/galaxy/dependency_resolution/providers.py

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

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
2 years ago
Jordan Borean 8482ee4e9a
galaxy build - ignore existing MANIFEST and FILES (#76479) 3 years ago
Martin Krizek f59d0456e1
galaxy: raise error when inaccessible path is specified multiple times (#76318)
Fixes #76316
3 years ago
Sviatoslav Sydorenko 5cbcf7c7bf Fix `galaxy.collection.galaxy_api_proxy` types 3 years ago