diff --git a/st2actions/st2actions/config.py b/st2actions/st2actions/config.py index 7a98134278..504c7e5eb3 100644 --- a/st2actions/st2actions/config.py +++ b/st2actions/st2actions/config.py @@ -28,13 +28,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(CONF) CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2actions/st2actions/notifier/config.py b/st2actions/st2actions/notifier/config.py index b18bb0417f..474d5447e5 100644 --- a/st2actions/st2actions/notifier/config.py +++ b/st2actions/st2actions/notifier/config.py @@ -21,17 +21,13 @@ from st2common.constants.system import VERSION_STRING from st2common.constants.system import DEFAULT_CONFIG_FILE_PATH -CONF = cfg.CONF - def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2actions/st2actions/scheduler/config.py b/st2actions/st2actions/scheduler/config.py index 422e52997b..614702f3f6 100644 --- a/st2actions/st2actions/scheduler/config.py +++ b/st2actions/st2actions/scheduler/config.py @@ -27,13 +27,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=sys_constants.VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2actions/st2actions/workflows/config.py b/st2actions/st2actions/workflows/config.py index 6983a074b0..4e54aef02c 100644 --- a/st2actions/st2actions/workflows/config.py +++ b/st2actions/st2actions/workflows/config.py @@ -23,13 +23,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=sys_constants.VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2api/st2api/config.py b/st2api/st2api/config.py index 6d5fe36b8a..e73c5c3936 100644 --- a/st2api/st2api/config.py +++ b/st2api/st2api/config.py @@ -32,13 +32,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2auth/st2auth/config.py b/st2auth/st2auth/config.py index 1a346c8464..061075db7b 100644 --- a/st2auth/st2auth/config.py +++ b/st2auth/st2auth/config.py @@ -28,13 +28,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = st2cfg.St2EnvironmentConfigurationSource() + st2cfg.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2common/st2common/config.py b/st2common/st2common/config.py index e3a802a15b..15a4d5b32a 100644 --- a/st2common/st2common/config.py +++ b/st2common/st2common/config.py @@ -908,13 +908,16 @@ def get_name(group_name, option_name): return "ST2_{}__{}".format(group_name.upper(), option_name.upper()) -def parse_args(args=None, ignore_errors=False): +def use_st2_env_vars(conf: cfg.ConfigOpts) -> None: # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = St2EnvironmentConfigurationSource() + conf._env_driver = St2EnvironmentConfigurationSource() + + +def parse_args(args=None, ignore_errors=False): + use_st2_env_vars(cfg.CONF) register_opts(ignore_errors=ignore_errors) cfg.CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2reactor/st2reactor/cmd/trigger_re_fire.py b/st2reactor/st2reactor/cmd/trigger_re_fire.py index acee891da6..d278aab835 100644 --- a/st2reactor/st2reactor/cmd/trigger_re_fire.py +++ b/st2reactor/st2reactor/cmd/trigger_re_fire.py @@ -48,8 +48,7 @@ def _parse_config(): CONF.register_cli_opts(cli_opts) st2cfg.register_opts(ignore_errors=False) - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - CONF._env_driver = st2cfg.St2EnvironmentConfigurationSource() + st2cfg.use_st2_env_vars(CONF) CONF(args=sys.argv[1:]) diff --git a/st2reactor/st2reactor/garbage_collector/config.py b/st2reactor/st2reactor/garbage_collector/config.py index febce172d7..66bf88bb5c 100644 --- a/st2reactor/st2reactor/garbage_collector/config.py +++ b/st2reactor/st2reactor/garbage_collector/config.py @@ -27,13 +27,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2reactor/st2reactor/rules/config.py b/st2reactor/st2reactor/rules/config.py index 98895fb7cd..d05ce44d1e 100644 --- a/st2reactor/st2reactor/rules/config.py +++ b/st2reactor/st2reactor/rules/config.py @@ -25,13 +25,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2reactor/st2reactor/sensor/config.py b/st2reactor/st2reactor/sensor/config.py index 653d30a276..f54a602167 100644 --- a/st2reactor/st2reactor/sensor/config.py +++ b/st2reactor/st2reactor/sensor/config.py @@ -26,13 +26,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = st2cfg.St2EnvironmentConfigurationSource() + st2cfg.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2reactor/st2reactor/timer/config.py b/st2reactor/st2reactor/timer/config.py index 9561de75e7..02c868cb8c 100644 --- a/st2reactor/st2reactor/timer/config.py +++ b/st2reactor/st2reactor/timer/config.py @@ -25,13 +25,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2stream/st2stream/config.py b/st2stream/st2stream/config.py index cbc83c055e..e820c249df 100644 --- a/st2stream/st2stream/config.py +++ b/st2stream/st2stream/config.py @@ -32,13 +32,11 @@ def parse_args(args=None): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(cfg.CONF) cfg.CONF( args=args, version=VERSION_STRING, default_config_files=[DEFAULT_CONFIG_FILE_PATH], - use_env=True, # Make our env var support explicit (default is True) ) diff --git a/st2tests/st2tests/config.py b/st2tests/st2tests/config.py index 575d6addd4..95bf49314f 100644 --- a/st2tests/st2tests/config.py +++ b/st2tests/st2tests/config.py @@ -39,11 +39,10 @@ def reset(): def parse_args(args=None, coordinator_noop=True): - # Override oslo_config's 'OS_' env var prefix with 'ST2_'. - cfg.CONF._env_driver = common_config.St2EnvironmentConfigurationSource() + common_config.use_st2_env_vars(cfg.CONF) _setup_config_opts(coordinator_noop=coordinator_noop) - kwargs = {"use_env": True} + kwargs = {} if USE_DEFAULT_CONFIG_FILES: kwargs["default_config_files"] = [DEFAULT_CONFIG_FILE_PATH]