Skip to content

Commit

Permalink
Add configvalidate.py script to allow config validation during deploy…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
Leigh Gordon committed Jan 18, 2021
1 parent 03d1090 commit 70f5a19
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
30 changes: 30 additions & 0 deletions aodncore/bin/configvalidate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python

"""Script to test the validity of pipeline configuration,
"""
import argparse
import os
from jsonschema.exceptions import ValidationError
from aodncore.pipeline.configlib import load_pipeline_config, validate_pipeline_config


def validate_config_file(pipeline_conf_file):
try:
print("validating pipeline config file '{path}'...".format(path=pipeline_conf_file))
pipeline_config = load_pipeline_config(pipeline_conf_file)
validate_pipeline_config(pipeline_config)
except ValidationError as e:
print("VALIDATION FAILED{nl}{nl}{e}".format(e=str(e), nl=os.linesep))
return 1
else:
print('VALIDATION SUCCEEDED')
return 0


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('path')
args = parser.parse_args()

exit(validate_config_file(args.path))
3 changes: 2 additions & 1 deletion aodncore/pipeline/configlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
'load_pipeline_config',
'load_trigger_config',
'load_watch_config',
'validate_lazyconfigmanager'
'validate_lazyconfigmanager',
'validate_pipeline_config'
]

DEFAULT_CONFIG_FILE = '/mnt/ebs/pipeline/etc/pipeline.conf'
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@

PACKAGE_EXCLUDES = ['test_aodncore.*', 'test_aodncore']
PACKAGE_NAME = 'aodncore'
PACKAGE_SCRIPTS = ['aodncore/bin/drawmachine.py', 'aodncore/pipeline/watchservice.py']
PACKAGE_SCRIPTS = [
'aodncore/bin/drawmachine.py',
'aodncore/bin/configvalidate.py',
'aodncore/pipeline/watchservice.py']

setup(
name=PACKAGE_NAME,
Expand Down

0 comments on commit 70f5a19

Please sign in to comment.