Skip to content

Commit

Permalink
config: allow reading teuthology config from env var location
Browse files Browse the repository at this point in the history
Allow changing the default "user" location of the teuthology
configuration yaml using the (optional) TEUTHOLOGY_CONFIG environment
variable. This change aids my effort to run a customized local
teuthology environment.

Signed-off-by: John Mulligan <[email protected]>
  • Loading branch information
phlogistonjohn committed Aug 14, 2024
1 parent 43b8805 commit 0410a2f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions teuthology/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class TeuthologyConfig(YamlConfig):
objects. Currently it serves as a convenient interface to
~/.teuthology.yaml and nothing else.
"""
yaml_path = os.path.join(os.path.expanduser('~/.teuthology.yaml'))
_defaults = {
'archive_base': '/home/teuthworker/archive',
'archive_upload': None,
Expand Down Expand Up @@ -285,10 +284,13 @@ def set_config_attr(obj):


def _get_config_path():
config_path = os.environ.get('TEUTHOLOGY_CONFIG', '~/.teuthology.yaml')
config_path = os.path.join(os.path.expanduser(config_path))
system_config_path = '/etc/teuthology.yaml'
if not os.path.exists(TeuthologyConfig.yaml_path) and \
os.path.exists(system_config_path):
return system_config_path
return TeuthologyConfig.yaml_path
for path in (config_path, system_config_path):
if os.path.exists(path):
return path
return None


config = TeuthologyConfig(yaml_path=_get_config_path())

0 comments on commit 0410a2f

Please sign in to comment.