From 7a27475c332afa2119b9368322176673c528c9ca Mon Sep 17 00:00:00 2001 From: Anush Shetty Date: Mon, 4 Sep 2017 16:00:14 +0530 Subject: [PATCH] Making the script interactive --- script/test/cmd/generate_unit.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/script/test/cmd/generate_unit.sh b/script/test/cmd/generate_unit.sh index a2a8fc4e9d..ba12018d14 100755 --- a/script/test/cmd/generate_unit.sh +++ b/script/test/cmd/generate_unit.sh @@ -14,31 +14,40 @@ # See the License for the specific language governing pe#rmissions and # limitations under the License. -KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..) +KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..) # Directory in which the output files have to be generated # Eg. script/test/fixtures/group-add/ -TEST_DIR='' - -# Location of the docker-compose file -COMPOSE_FILE="${TEST_DIR}/docker-compose.yml" +echo -n "Enter the Test Directory where the files needs to be generated: " +read TEST_DIR # One-line description for the test case -TEST_DESCRIPTION='' +echo -ne "\nEnter a description for the tests to be added: " +read TEST_DESCRIPTION -if [ -z $TEST_DIR ] || [ -z $COMPOSE_FILE ] || [ -z $TEST_DESCRIPTION ]; then - echo "Please provide values for TEST_DIR, COMPOSE_FILE and TEST_DESCRIPTION in the script" +echo -ne "\nPlease provide the name of docker-compose file to be used (docker-compose.yaml by default): " +read COMPOSE_FILE + +if [ -z $COMPOSE_FILE ]; then + COMPOSE_FILE="docker-compose.yaml" +fi + + +if [ -z $TEST_DIR ] || [ -z "${TEST_DESCRIPTION}" ]; then + echo "Please provide values for TEST_DIR and TEST_DESCRIPTION in the script" exit 1; fi +COMPOSE_FILE=$TEST_DIR/$COMPOSE_FILE + generate_k8s() { - kompose convert -f $COMPOSE_FILE -j -o $TEST_DIR/output-k8s.json + ./kompose convert -f $COMPOSE_FILE -j -o $TEST_DIR/output-k8s.json sed -i -e '/.*kompose.cmd.*:/ s/: .*/: "%CMD%"/' -e '/.*kompose.version.*:/ s/: .*/: "%VERSION%"/' ${TEST_DIR}/output-k8s.json } generate_os() { - kompose convert --provider=openshift -f $COMPOSE_FILE -j -o $TEST_DIR/output-os.json + ./kompose convert --provider=openshift -f $COMPOSE_FILE -j -o $TEST_DIR/output-os.json sed -i -e '/.*kompose.cmd.*:/ s/: .*/: "%CMD%"/' -e '/.*kompose.version.*:/ s/: .*/: "%VERSION%"/' ${TEST_DIR}/output-os.json } @@ -48,8 +57,7 @@ generate_k8s # Generate OS files generate_os -cat > $KOMPOSE_ROOT/script/test/cmd/tests.sh <> $KOMPOSE_ROOT/script/test/cmd/tests.sh <