mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Save the command line arguments into a global context
* Once cli args are parsed, they're constant. So, save the parsed args
into the global context for everyone else to use them from now on.
* Port cli scripts to use the CLIARGS in the context
* Refactor call to parse cli args into the run() method
* Fix unittests for changes to the internals of CLI arg parsing
* Port callback plugins to use context.CLIARGS
* Got rid of the private self._options attribute
* Use context.CLIARGS in the individual callback plugins instead.
* Also output positional arguments in default and unixy plugins
* Code has been simplified since we're now dealing with a dict rather
than Optparse.Value
This commit is contained in:
@@ -24,6 +24,7 @@ __metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
from ansible import context
|
||||
import ansible.constants as C
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.galaxy.token import GalaxyToken
|
||||
@@ -63,7 +64,7 @@ class GalaxyAPI(object):
|
||||
self.galaxy = galaxy
|
||||
self.token = GalaxyToken()
|
||||
self._api_server = C.GALAXY_SERVER
|
||||
self._validate_certs = not galaxy.options.ignore_certs
|
||||
self._validate_certs = not context.CLIARGS['ignore_certs']
|
||||
self.baseurl = None
|
||||
self.version = None
|
||||
self.initialized = False
|
||||
@@ -71,8 +72,8 @@ class GalaxyAPI(object):
|
||||
display.debug('Validate TLS certificates: %s' % self._validate_certs)
|
||||
|
||||
# set the API server
|
||||
if galaxy.options.api_server != C.GALAXY_SERVER:
|
||||
self._api_server = galaxy.options.api_server
|
||||
if context.CLIARGS['api_server'] != C.GALAXY_SERVER:
|
||||
self._api_server = context.CLIARGS['api_server']
|
||||
|
||||
def __auth_header(self):
|
||||
token = self.token.get()
|
||||
|
||||
Reference in New Issue
Block a user