Add ENTRYPOINT_PRECONF_COMMAND and ENTRYPOINT_POSTCONF_COMMAND in env configuration

pull/3/head v0.3.4
Christophe Mehay 8 years ago
parent 4a56f62f71
commit 248ce38c88

@ -227,6 +227,8 @@ Some setups can be overridden using environment variables.
- `ENTRYPOINT_CONFIG` overrides path of `entrypoint-config.yml` file.
- `ENTRYPOINT_FORCE` is applying configuration and runs pre and post conf commands even if the `command` provided is not handled.
- `ENTRYPOINT_PRECONF_COMMAND` run an extra pre conf shell command after all pre conf commands.
- `ENTRYPOINT_POSTCONF_COMMAND` run an extra post conf shell command after all post conf commands.
- `ENTRYPOINT_DEBUG` enables debug logs.
- `ENTRYPOINT_RAW` does not use logging to display pre and post conf commands.
This can be useful if output is serialized.

@ -7,6 +7,10 @@ Some setups can be overridden using environment variables in the container.
file.
- ``ENTRYPOINT_FORCE`` applies configuration and runs pre and post conf
commands even if the ``command`` provided is not handled.
- ``ENTRYPOINT_PRECONF_COMMAND`` run an extra pre conf shell command after
all pre conf commands.
- ``ENTRYPOINT_POSTCONF_COMMAND`` run an extra post conf shell command after
all post conf commands.
- ``ENTRYPOINT_DEBUG`` enables debug logs.
- ``ENTRYPOINT_RAW`` does not use logging to display pre and post conf commands.
This can be useful if output is serialized.

@ -101,10 +101,14 @@ class Entrypoint(object):
def run_pre_conf_cmds(self):
for cmd in self.config.pre_conf_commands:
self.run_conf_cmd(cmd)
if 'ENTRYPOINT_PRECONF_COMMAND' in os.environ:
self.run_conf_cmd(os.environ['ENTRYPOINT_PRECONF_COMMAND'])
def run_post_conf_cmds(self):
for cmd in self.config.post_conf_commands:
self.run_conf_cmd(cmd)
if 'ENTRYPOINT_POSTCONF_COMMAND' in os.environ:
self.run_conf_cmd(os.environ['ENTRYPOINT_POSTCONF_COMMAND'])
def launch(self):
self.config.command.run()

@ -5,7 +5,7 @@ from setuptools import setup
# Thanks Sam and Max
__version__ = '0.3.3'
__version__ = '0.3.4'
if __name__ == '__main__':
setup(

@ -148,10 +148,11 @@ def test_templates():
def test_conf_commands():
entry = Entrypoint(conf='configs/base.yml')
for cmd in entry.config.pre_conf_commands:
entry.run_conf_cmd(cmd)
for cmd in entry.config.post_conf_commands:
entry.run_conf_cmd(cmd)
os.environ['ENTRYPOINT_PRECONF_COMMAND'] = 'echo TEST4 > /tmp/OKOKOKOK'
os.environ['ENTRYPOINT_POSTCONF_COMMAND'] = 'echo TEST5 > /tmp/OKOKOKOKOK'
entry.run_pre_conf_cmds()
entry.run_post_conf_cmds()
with open('/tmp/OK') as f:
assert f.readline().startswith('TEST')
@ -162,6 +163,12 @@ def test_conf_commands():
with open('/tmp/OKOKOK') as f:
assert f.readline().startswith('TEST3')
with open('/tmp/OKOKOKOK') as f:
assert f.readline().startswith('TEST4')
with open('/tmp/OKOKOKOKOK') as f:
assert f.readline().startswith('TEST5')
def test_command():
run = [

Loading…
Cancel
Save