#!/bin/bash -xe

PLUGIN=$1

case "$PLUGIN" in
    "cloudera")
        # manually call each distro for cloudera, so we can cleanup
        # cache and generated images from the previous run
        # (saving space a bit)
        for distro in ubuntu centos; do
            tox -e venv -- sahara-image-create -x -u -p $PLUGIN -i $distro
            find . -maxdepth 1 -name '*cloudera*.qcow2' -delete
            sudo rm -rf ~/.cache/image-create
        done
        ;;
    # this case is needed until we use ambari version <= 2.1.1
    "ambari")
        tox -e venv -- sahara-image-create -x -u -p $PLUGIN -i "centos"
        ;;
    *)
        tox -e venv -- sahara-image-create -x -u -p $PLUGIN
        ;;
esac
