mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 08:37:48 -02:30
import awxkit
Co-authored-by: Christopher Wang <cwang@ansible.com> Co-authored-by: Jake McDermott <jmcdermott@ansible.com> Co-authored-by: Jim Ladd <jladd@redhat.com> Co-authored-by: Elijah DeLee <kdelee@redhat.com> Co-authored-by: Alan Rominger <arominge@redhat.com> Co-authored-by: Yanis Guenane <yanis@guenane.org>
This commit is contained in:
34
awxkit/awxkit/config.py
Normal file
34
awxkit/awxkit/config.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import types
|
||||
import os
|
||||
|
||||
from .utils import (
|
||||
PseudoNamespace,
|
||||
load_credentials,
|
||||
load_projects,
|
||||
to_bool,
|
||||
)
|
||||
|
||||
config = PseudoNamespace()
|
||||
|
||||
|
||||
def getvalue(self, name):
|
||||
return self.__getitem__(name)
|
||||
|
||||
|
||||
if os.getenv('AWXKIT_BASE_URL'):
|
||||
config.base_url = os.getenv('AWXKIT_BASE_URL')
|
||||
|
||||
if os.getenv('AWXKIT_CREDENTIAL_FILE'):
|
||||
config.credentials = load_credentials(os.getenv('AWXKIT_CREDENTIAL_FILE'))
|
||||
|
||||
if os.getenv('AWXKIT_PROJECT_FILE'):
|
||||
config.project_urls = load_projects(config.get('AWXKIT_PROJECT_FILE'))
|
||||
|
||||
# kludge to mimic pytest.config
|
||||
config.getvalue = types.MethodType(getvalue, config)
|
||||
|
||||
config.assume_untrusted = config.get('assume_untrusted', True)
|
||||
|
||||
config.client_connection_attempts = int(os.getenv('AWXKIT_CLIENT_CONNECTION_ATTEMPTS', 5))
|
||||
config.prevent_teardown = to_bool(os.getenv('AWXKIT_PREVENT_TEARDOWN', False))
|
||||
config.use_sessions = to_bool(os.getenv('AWXKIT_SESSIONS', False))
|
||||
Reference in New Issue
Block a user