Add warning if entrypoint-config contains invalid parameters

pull/3/head
Christophe Mehay 8 years ago
parent 5c2003a0f2
commit 251477719e

@ -22,15 +22,7 @@ from .logs import Logs
__all__ = ['Config']
class Config(object):
"""
Get entrypoint config
Parse entrypoint-config.yml
Config file should always be in WORKDIR and named entrypoint-config.yml
"""
class ConfigMeta(object):
def _return_item_lst(self, item):
"""Return item as a list"""
@ -55,6 +47,24 @@ class Config(object):
if isinstance(config_files, dict):
raise Exception("config_files setup missformated.")
def _check_config(self):
for key in self._config:
if not hasattr(Config, key) or key == '__init__':
self.log.warning(
'"{key}" is not a valid option'.format(key=key)
)
class Config(ConfigMeta):
"""
Get entrypoint config
Parse entrypoint-config.yml
Config file should always be in WORKDIR and named entrypoint-config.yml
"""
def __init__(self, conf=ENTRYPOINT_FILE, args=[]):
self._config = {}
self.log = Logs().log
@ -67,6 +77,7 @@ class Config(object):
return
with open(self._config_file) as f:
self._config = load(stream=f, Loader=Loader)
self._check_config()
@property
def has_config(self):

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

@ -0,0 +1,39 @@
command: bash
user: 1000
group: 1000
config_files:
- /tmp/test_template.yml
- /tmp/test_template2.yml.tpl
- /tmp/test_template2.yml.tpl: /tmp/test_template3.yml
secret_env:
- SECRET
links:
test1:
name: test1
test2_800:
port: 800
protocol: udp
single: true
test2:
env:
FOO: bar
required: true
# Error
preconf_commands:
- echo TEST > /tmp/OK
- echo "INFO IS DISPLAYED"
- echo "WARNING IS DISPLAYED\nON TWO LINES" 1>&2
# error
postconf_commands:
- echo TEST2 > /tmp/OKOK
- echo TEST3 > /tmp/OKOKOK
- echo "INFO IS DISPLAYED\nON TWO LINES"
- echo "WARNING IS DISPLAYED" 1>&2
debug: true

@ -76,6 +76,14 @@ def test_main():
'/tmp/CMD11',
0,
0,
), (
Process(target=ProxyMain(
args=['pyentrypoint', 'bash', '-c', 'echo OK > /tmp/CMD12'],
env={'ENTRYPOINT_CONFIG': 'configs/base_with_errors.yml'}
).run),
'/tmp/CMD12',
1000,
1000,
)
]

Loading…
Cancel
Save