Skip to content

Commit

Permalink
Making the script interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
ashetty1 committed Sep 4, 2017
1 parent 7f71f58 commit 7a27475
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions script/test/cmd/generate_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -48,8 +57,7 @@ generate_k8s
# Generate OS files
generate_os

cat > $KOMPOSE_ROOT/script/test/cmd/tests.sh <<EOF
cat >> $KOMPOSE_ROOT/script/test/cmd/tests.sh <<EOF
# ${TEST_DESCRIPTION}
cmd="kompose -f \$KOMPOSE_ROOT/${COMPOSE_FILE} convert --stdout -j"
Expand Down

0 comments on commit 7a27475

Please sign in to comment.