return volume_list
-def invoke_docker(bluprint, layer):
+def invoke_docker(bluprint, layer, tag):
"""Start docker container for given layer
"""
volume_list = get_volumes('common') + get_volumes(layer)
cmd = ("docker run --rm" + volume_list + _SUBNET +
- " akraino/validation:{0}-latest"
+ " akraino/validation:{0}-{3}"
" /bin/sh -c"
" 'cd /opt/akraino/validation "
"&& python -B bluval/bluval.py -l {0} {1} {2}'"
- .format(layer, ("-o" if _OPTIONAL_ALSO else ""), bluprint))
+ .format(layer, ("-o" if _OPTIONAL_ALSO else ""), bluprint, tag))
args = [cmd]
try:
raise BluvalError(OSError)
-def invoke_dockers(yaml_loc, layer, blueprint_name):
+def invoke_dockers(yaml_loc, layer, blueprint_name, tag):
"""Parses yaml file and starts docker container for one/all layers
"""
with open(str(yaml_loc)) as yaml_file:
blueprint = yamldoc['blueprint']
if layer is None or layer == "all":
for each_layer in blueprint['layers']:
- invoke_docker(blueprint_name, each_layer)
+ invoke_docker(blueprint_name, each_layer, tag)
else:
- invoke_docker(blueprint_name, layer)
+ invoke_docker(blueprint_name, layer, tag)
@click.command()
@click.argument('blueprint')
@click.option('--layer', '-l')
@click.option('--network', '-n')
+@click.option('--tag', '-t')
@click.option('--optional_also', '-o', is_flag=True)
-def main(blueprint, layer, network, optional_also):
+def main(blueprint, layer, network, tag, optional_also):
"""Takes blueprint name and optional layer. Validates inputs and derives
- yaml location from blueprint name. Invokes validate on blue print.
+ yaml location from blueprint name. Invokes validate on blueprint.
"""
global _OPTIONAL_ALSO # pylint: disable=global-statement
global _SUBNET # pylint: disable=global-statement
if network is not None:
_SUBNET = " --net=" + network
print("Using", _SUBNET)
+ if tag is None:
+ tag = 'latest'
+ print("Using tag {}".format(tag))
try:
- invoke_dockers(yaml_loc, layer, blueprint)
+ invoke_dockers(yaml_loc, layer, blueprint, tag)
except ShowStopperError as err:
print('ShowStopperError:', err)
except BluvalError as err:
if [ -z "$AKRAINO_HOME" ]
then
- echo "AKRAINO_HOME not available. Setting..."
- this_file="$(readlink -f $0)"
- bluval_dir="$(dirname $this_file)"
- validation_dir="$(dirname $bluval_dir)"
- parent_dir="$(dirname $validation_dir)"
- export AKRAINO_HOME="$parent_dir"
+ echo "AKRAINO_HOME not available. Setting ..."
+ AKRAINO_HOME="$(readlink -f "$(dirname "$0")/../..")"
fi
+
+# Allow overriding VALIDATION_DIR and/or RESULTS_DIR via env vars
+VALIDATION_DIR=${VALIDATION_DIR:-"${AKRAINO_HOME}/validation"}
+RESULTS_DIR=${RESULTS_DIR:-"${AKRAINO_HOME}/results"}
+
echo "AKRAINO_HOME=$AKRAINO_HOME"
+echo "VALIDATION_DIR=$VALIDATION_DIR"
+echo "RESULTS_DIR=$RESULTS_DIR"
if [ "$#" -eq 0 ]
then
Options:
-l, --layer TEXT
-n, --network TEXT
+ -t, --tag TEXT
-o, --optional_also
--help Show this message and exit.'
fi
echo "Building docker image"
-image_tag=$( (git branch || echo "* local") | grep "^\*" | awk '{print $2}')
-docker build -t akraino/validation:blucon-$image_tag $AKRAINO_HOME/validation/bluval
+img="akraino/validation:blucon-$(git rev-parse --abbrev-ref HEAD || echo local)"
+docker build -t "$img" "$VALIDATION_DIR/bluval"
set -x
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
- -v $AKRAINO_HOME/results:/opt/akraino/results \
- -v $AKRAINO_HOME/validation:/opt/akraino/validation \
- akraino/validation:blucon-$image_tag "$@"
+ -v "$RESULTS_DIR":/opt/akraino/results \
+ -v "$VALIDATION_DIR":/opt/akraino/validation \
+ "$img" "$@"