-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: allow reading teuthology config from env var location #1998
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bad style, overriding variable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also if we declare the env for the config, we should stop immediately if such file does not exists. |
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea was to always return a meaningful value, see usage of config constructor below. |
||
|
||
|
||
config = TeuthologyConfig(yaml_path=_get_config_path()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if drop this line you have to update the comment above about "interface to ~/.teuthology.yaml and nothing else".