Add SERVER_ENV_CONFIG_SECRET alongside SERVER_ENV_CONFIG
Allows to isolate the secrets in your deployment
This commit is contained in:
parent
ec14e3da0a
commit
d52e93a743
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue