diff --git a/server_environment/README.rst b/server_environment/README.rst index a68bc25..a31a143 100644 --- a/server_environment/README.rst +++ b/server_environment/README.rst @@ -27,6 +27,8 @@ the incoming and outgoing mail servers depending on the environment. To install this module, you need to provide a companion module called `server_environment_files`. You can copy and customize the provided `server_environment_files_sample` module for this purpose. +You can provide additional options in environment variables +``SERVER_ENV_CONFIG`` and ``SERVER_ENV_CONFIG_SECRET``. Configuration @@ -48,11 +50,11 @@ You should then edit the settings you need in the * each environment you need to define is stored in its own directory and can override or extend default values; * you can override or extend values in the main configuration - file of you instance; + file of your instance; * additional configuration can be passed in the environment variable - ``SERVER_ENV_CONFIG``, overriding any values set in the configuration files. - This is a multi-line environment variable in the same configparser format than - the files. + ``SERVER_ENV_CONFIG`` and/or ``SERVER_ENV_CONFIG_SECRET``, overriding any + values set in the configuration files. This is a multi-line environment + variable in the same configparser format than the files. Values associated to keys containing 'passw' are only displayed in the 'dev' environment. diff --git a/server_environment/serv_config.py b/server_environment/serv_config.py index 5bc3500..17ba30e 100644 --- a/server_environment/serv_config.py +++ b/server_environment/serv_config.py @@ -31,6 +31,8 @@ from .system_info import get_server_environment from odoo.addons import server_environment_files _dir = os.path.dirname(server_environment_files.__file__) +ENV_VAR_NAMES = ('SERVER_ENV_CONFIG', 'SERVER_ENV_CONFIG_SECRET') + # Same dict as RawConfigParser._boolean_states _boolean_states = {'1': True, 'yes': True, 'true': True, 'on': True, '0': False, 'no': False, 'false': False, 'off': False} @@ -101,15 +103,16 @@ def _load_config(): config_p.read(system_base_config.rcfile) config_p.remove_section('options') - env_config = os.getenv('SERVER_ENV_CONFIG') - if env_config: - try: - config_p.read_string(env_config) - except configparser.Error as err: - raise Exception( - 'SERVER_ENV_CONFIG content could not be parsed: %s' - % (err,) - ) + for varname in ENV_VAR_NAMES: + env_config = os.getenv(varname) + if env_config: + try: + config_p.read_string(env_config) + except configparser.Error as err: + raise Exception( + '%s content could not be parsed: %s' + % (varname, err,) + ) return config_p