Commit graph

15 commits

Author SHA1 Message Date
Sloane Hertel
00bd0b893d
ansible-galaxy - set the cache file after getting all collection versions ()
* Manage the in-memory cache in _call_galaxy but let the caller set the file cache after getting paginated results

* Add a test for caching successful and not caching unsuccessful paginated results

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
2021-02-15 09:45:01 -05:00
Jordan Borean
de5858f48d
Added caching mechanism for Galaxy API requests ()
* Added caching mechanism for Galaxy API requests

* Add cache options and split up code

* Added unit tests

* Fix sanity test

* Use modified date and fix up caching for explicit servers

* Make sure credentials are not in cached server name

* Added test for getting updated cache version

* Changes from review
2020-11-10 06:50:32 +10:00
Matt Davis
83909bfa22
Remove ansible-galaxy login ()
* GitHub is removing the underlying API used to implement the `login` command. Since the general consensus seems to be that relatively nobody currently uses this command (in favor of explicit token passing), support was simply removed for interactive login. If a future need arises, this command should be reimplemented via OAuth Device Auth Grants.
* login or role login commands now produce a fatal error with a descriptive message
* updated 2.10 and 2.11 porting guide entries

* remove dead code/config, update messages and porting guides
2020-10-23 09:11:45 -07:00
Matt Martz
b748edea45
Add multipart/form-data functionality ()
* Add multipart/form-data functionality

* Fix some linting issues

* Fix error message

* Allow filename to be provided with content

* Add integration test

* Update examples

* General improvements to multipart handling

* Use prepare_multipart for galaxy collection publish

* Properly account for py2 vs py3, ensuring no max header length

* Address test assumptions

* Add unit tests

* Add changelog

* Ensure to use CRLF instead of NL

* Ignore line-endings in fixture

* Consolidate code, add comment

* Bump fallaxy container version

* ci_complete
2020-05-20 15:44:01 -05:00
Jordan Borean
26129fcb80
ansible-galaxy - optimise some paths and use fake galaxy int tests ()
* ansible-galaxy - optimise some paths and use fake galaxy int tests

* Added init, built, and publish tests

* Test against both mocked Galaxy and AH server

* Finish off writing the install tests

* Fix up broken tests

* Rename test target and add migrated tests

* Use cloud provider for Galaxy implementation

* Added blank static config

* Use correct alias group

* Set release version and fix copy typo

* Remove reset step as it is no longer needed

* Use sane env var names for test container name
2020-02-29 08:59:09 +10:00
Adrian Likins
d1c39b9068 Don't remove trailing / on galaxy api URLS ()
This causes multiple unneeded http redirects.
Since each http redirect takes a few hundred
milliseconds, handling the redirects starts to
take up a significant amount of wall time.

Fixes: 
2020-01-08 15:25:40 -05:00
Jordan Borean
eaba5572cd
ansible-galaxy - expand User-Agent string for Galaxy endpoints () 2019-12-06 10:34:14 +10:00
Jordan Borean
6586b7132c
galaxy - print HTTP reason on unknown error () 2019-12-03 07:36:05 +10:00
Jordan Borean
7acae62fa8 Fix up role version pagination for Galaxy install ()
* Fix up role version pagination for Galaxy install

* Fix sanity issue
2019-11-05 10:34:50 -05:00
Toshio Kuratomi
cc1ff57c5b
AH servers include automation-hub as part of the server configuration. ()
* AH servers include automation-hub as part of the server configuration.

So we don't need to add it here.

Fixes 

* Update unittests for the fix to galaxy wait_import_task
2019-10-19 12:40:45 -07:00
Toshio Kuratomi
4cad7e479c
Galaxy publish fix ()
* Handle galaxy v2/v3 API diffs for artifact publish response

For publishing a collection artifact
(POST /v3/collections/artifacts/), the response
format is different between v2 and v3.

For v2 galaxy, the 'task' url returned is
a full url with scheme:

        {"task": "https://galaxy-dev.ansible.com/api/v2/collection-imports/35573/"}

For v3 galaxy, the task url is relative:

        {"task": "/api/automation-hub/v3/imports/collections/838d1308-a8f4-402c-95cb-7823f3806cd8/"}

So check which API we are using and update the task url approriately.

* Use full url for all wait_for_import messages

Update unit tests to parameterize the expected
responses and urls.

* update explanatory comment

* Rename n_url to full_url.

* Fix issue with overwrite of the complete path

* Fixes overwrite of the complete path in case there's extra path stored
  in self.api_sever
* Normalizes the input to the wait_import_task function so it receives
  the same value on both v2 and v3

Builds on 

* Update unittests for new call signature

* Add changelog for ansible-galaxy publish API fixes.
2019-10-16 15:23:12 -07:00
Adrian Likins
bad72693e4 Stop appending '/api' to galaxy server url ()
* Stop appending '/api' to configured galaxy server url

Since not all galaxy REST api server URLs live
at '/api', stop always appending it to the
'url' value loaded from config.

* Add note about manually migrated galaxy configs and /api

* Add '/api/' to galaxy url and guessing if galaxy API

* Fix most unit tests (update to expect /api/)

* Fix test_initialise_unknown unit test

Since we retry now with an added /api/, mock it as well.

* Update fallback default avail_ver to new format
2019-10-08 15:09:19 -07:00
Adrian Likins
239d639fee Add support for automation-hub authentication to ansible-galaxy ()
Adds support for token authentication in Automation Hub. Fixes: 
2019-10-04 17:57:37 -04:00
Jordan Borean
a7fd6e99d9
Refactor galaxy collection API for v3 support ()
* Refactor galaxy collection API for v3 support

* Added unit tests for GalaxyAPI and starting to fix other failures

* finalise tests

* more unit test fixes
2019-08-30 11:55:19 +10:00
Jordan Borean
e747487720
ansible-galaxy - define multiple galaxy instances in ansible.cfg ()
* ansible-galaxy: support multiple servers on install

* Added docs for the server configuration file

* Fix up doc string for requirements file format

* Fix bugs after testing

* Fix kwarg doc and added version

* Fix typo and doc improvement

* Fix base64 encoding and allow --server to override list
2019-08-21 07:49:05 +10:00