<commit_before>#!/bin/bash

set -e

CLOUD_DOMAIN=${DOMAIN:-run.pivotal.io}
CLOUD_TARGET=api.${DOMAIN}

function login(){
    cf api | grep ${CLOUD_TARGET} || cf api ${CLOUD_TARGET} --skip-ssl-validation
    cf a | grep OK || cf login
}

function app_domain(){
    echo `cf apps | grep $1 | tr -s ' ' | cut -d' ' -f 6 | cut -d, -f1`
}

function deploy_app(){
    APP_NAME=$1
    cd $APP_NAME
    cf push $APP_NAME  --no-start
    APPLICATION_DOMAIN=`app_domain $APP_NAME`
    cf env $APP_NAME | grep APPLICATION_DOMAIN || cf set-env $APP_NAME APPLICATION_DOMAIN $APPLICATION_DOMAIN
    cf restart $APP_NAME
    cd ..
}

function deploy_service(){
    N=$1
    D=`app_domain $N`
    JSON='{"uri":"http://'$D'"}'
    echo cf cups $N  -p $JSON
    cf cups $N -p $JSON
}

function deploy_config_service(){
    NAME=config-service
    deploy_app $NAME
    deploy_service $NAME
}

function deploy_eureka_service(){
    NAME=eureka-service
    deploy_app $NAME
    deploy_service $NAME
}

function deploy_reservation_service(){
    cf cs elephantsql turtle reservations-postgresql
    deploy_app reservation-service
}

function deploy_reservation_client(){
    deploy_app reservation-client
}

function reset(){

    apps="reservation-service reservation-client config-service eureka-service"
    apps_arr=( $apps )
    for a in "${apps_arr[@]}";
    do
         echo $a
         cf d -f $a
    done

    services="reservations-postgresql config-service eureka-service"
    services_arr=( $services )
    for s in "${services_arr[@]}";
    do
        cf ds -f $s
    done

    cf delete-orphaned-routes -f
}

###
### INSTALLATION STEPS
###

mvn -DskipTests=true clean install

login
reset
deploy_config_service
deploy_eureka_service
deploy_reservation_service
deploy_reservation_client
<commit_msg>removed extra build incantation<commit_after>#!/bin/bash

set -e

CLOUD_DOMAIN=${DOMAIN:-run.pivotal.io}
CLOUD_TARGET=api.${DOMAIN}

function login(){
    cf api | grep ${CLOUD_TARGET} || cf api ${CLOUD_TARGET} --skip-ssl-validation
    cf a | grep OK || cf login
}

function app_domain(){
    echo `cf apps | grep $1 | tr -s ' ' | cut -d' ' -f 6 | cut -d, -f1`
}

function deploy_app(){
    APP_NAME=$1
    cd $APP_NAME
    cf push $APP_NAME  --no-start
    APPLICATION_DOMAIN=`app_domain $APP_NAME`
    cf env $APP_NAME | grep APPLICATION_DOMAIN || cf set-env $APP_NAME APPLICATION_DOMAIN $APPLICATION_DOMAIN
    cf restart $APP_NAME
    cd ..
}

function deploy_service(){
    N=$1
    D=`app_domain $N`
    JSON='{"uri":"http://'$D'"}'
    echo cf cups $N  -p $JSON
    cf cups $N -p $JSON
}

function deploy_config_service(){
    NAME=config-service
    deploy_app $NAME
    deploy_service $NAME
}

function deploy_eureka_service(){
    NAME=eureka-service
    deploy_app $NAME
    deploy_service $NAME
}

function deploy_reservation_service(){
    cf cs elephantsql turtle reservations-postgresql
    deploy_app reservation-service
}

function deploy_reservation_client(){
    deploy_app reservation-client
}

function reset(){

    apps="reservation-service reservation-client config-service eureka-service"
    apps_arr=( $apps )
    for a in "${apps_arr[@]}";
    do
         echo $a
         cf d -f $a
    done

    services="reservations-postgresql config-service eureka-service"
    services_arr=( $services )
    for s in "${services_arr[@]}";
    do
        cf ds -f $s
    done

    cf delete-orphaned-routes -f
}

###
### INSTALLATION STEPS
###



login
reset
deploy_config_service
deploy_eureka_service
deploy_reservation_service
deploy_reservation_client

{'fraction_non_alphanumeric': 0.11616161616161616, 'fraction_numerical': 0.0028058361391694723, 'mean_word_length': 3.3159806295399514, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1809346', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1218, 'n_words': 311}