<commit_before>#!/usr/bin/env bash

# Example :
# Token                         --> ./release-openshift.sh -a https://api.engint.openshift.com -t xxxxxxxxxxxx
# User/password (CI Server)     --> ./release-openshift.sh -a https://172.16.50.40:8443 -u admin -p admin
# User/password (local vagrant) --> ./release-openshift.sh -a 172.28.128.4:8443 -u admin -p admin \
#                                                          -v 1.0.0-SNAPSHOT
#                                                          -b http://backend-generator-obsidian-dummy.172.28.128.4.xip.io/ \
#                                                          -c http://nexus-infra.172.28.128.4.xip.io/content/repositories/releases/org/obsidiantoaster/archetypes-catalog/1.0.0.Dummy/archetypes-catalog-1.0.0.Dummy-archetype-catalog.xml \
#                                                          -n http://nexus-infra.172.28.128.4.xip.io/content/repositories/releases

while getopts a:t:u:p:v:b:c:n: option
do
        case "${option}"
        in
                a) api=${OPTARG};;
                t) token=${OPTARG};;
                u) user=${OPTARG};;
                p) password=${OPTARG};;
                v) version=${OPTARG};;
                b) backendurl=${OPTARG};;
                c) archetypecatalog=${OPTARG};;
                n) nexusserver=${OPTARG};;

        esac
done

current=$PWD

echo "Deploy Front & Backend to OpenShift"
if [ "$token" != "" ]; then
   oc login $api --token=$token
else
   echo "oc login $api -u $user -p $password"
   oc login $api -u $user -p $password
fi

REL=$version
BRANCH="master"
echo "Version for the front : $REL"
echo "Branch : $BRANCH"
echo "Backend : $backendurl"
echo "Github Org : $githuborg"
echo "Catalog URL : $archetypecatalog"
echo "Nexus Server : $nexusserver"

# Change version
sed -e "s/VERSION/$BRANCH/g" -e "s/ORG\//$githuborg\//g" -e "s|NEXUSSERVER|$nexusserver|g" -e "s|ARCHETYPECATALOG|$archetypecatalog|g" ./templates/backend.yml > ./templates/backend-$REL.yml
sed -e "s/VERSION/$REL/g" -e "s|GENERATOR_URL|$backendurl|g" -e "s/ORG\//$githuborg\//g" ./templates/front.yml > ./templates/front-$REL.yml

#
# Remove first 6 chars otherwise OpenShift will complaints --> metadata.name: must match the regex [a-z0-9]([-a-z0-9]*[a-z0-9])? (e.g. 'my-name' or '123-abc')
#
suffix=${REL:6}
suffix_lower=$(echo $suffix | tr '[:upper:]' '[:lower:]')

echo Press any key to create OpenShift Project and deploy ...
read junk

# Create project
oc new-project obsidian-$suffix_lower
sleep 5

# Deploy the backend
echo "Deploy the backend ..."
oc create -f ./templates/backend-$REL.yml
oc process backend-generator-s2i | oc create -f -
oc start-build backend-generator-s2i

# Deploy the Front
echo "Deploy the frontend ..."
oc create -f templates/front-$REL.yml
oc process front-generator-s2i | oc create -f -
oc start-build front-generator-s2i

<commit_msg>Define new env vars<commit_after>#!/usr/bin/env bash

# Example :
# Token                         --> ./deploy-openshift.sh -a https://api.engint.openshift.com -t xxxxxxxxxxxx
# User/password (CI Server)     --> ./deploy-openshift.sh -a https://172.16.50.40:8443 -u admin -p admin
# User/password (local vagrant) --> ./deploy-openshift.sh  -a 172.28.128.4:8443 -u admin -p admin \
#                                                          -v 1.0.0-SNAPSHOT \
#                                                          -b http://backend-generator-obsidian-snapshot.172.28.128.4.xip.io/ \
#                                                          -c 'http://nexus-infra.172.28.128.4.xip.io/service/local/artifact/maven/redirect?r=public\&g=org.obsidiantoaster\&a=archetypes-catalog\&v=1.0.0-SNAPSHOT\&e=xml&c=archetype-catalog' \
#                                                          -n http://nexus-infra.172.28.128.4.xip.io

while getopts a:t:u:p:v:b:c:n: option
do
        case "${option}"
        in
                a) api=${OPTARG};;
                t) token=${OPTARG};;
                u) user=${OPTARG};;
                p) password=${OPTARG};;
                v) version=${OPTARG};;
                b) backendurl=${OPTARG};;
                c) archetypecatalog=${OPTARG};;
                n) mavenserver=${OPTARG};;

        esac
done

current=$PWD

echo "Deploy Front & Backend to OpenShift"
if [ "$token" != "" ]; then
   oc login $api --token=$token
else
   echo "oc login $api -u $user -p $password"
   oc login $api -u $user -p $password
fi

REL=$version
BRANCH="master"
githuborg="obsidian-toaster"
mavenmirrorurl=$mavenserver/content/repositories/snapshots

echo "Version for the front : $REL"
echo "Branch : $BRANCH"
echo "Backend : $backendurl"
echo "Github Org : $githuborg"
echo "Catalog URL : $archetypecatalog"
echo "Maven Server : $mavenserver"
echo "Maven Mirror URL : $mavenmirrorurl"

# Change version
sed -e "s/VERSION/$REL/g" -e "s/BRANCH/$BRANCH/g" -e "s/ORG\//$githuborg\//g" -e "s|MAVENSERVER|$mavenserver|g" -e "s|MAVENMIRRORURL|$mavenmirrorurl|g"  -e "s|ARCHETYPECATALOG|$archetypecatalog|" ./templates/backend-deploy.yml > ./templates/backend-$REL.yml
sed -e "s/VERSION/$REL/g" -e "s|GENERATOR_URL|$backendurl|g" -e "s/ORG\//$githuborg\//g" ./templates/front.yml > ./templates/front-$REL.yml

#
# Remove first 6 chars otherwise OpenShift will complaints --> metadata.name: must match the regex [a-z0-9]([-a-z0-9]*[a-z0-9])? (e.g. 'my-name' or '123-abc')
#
suffix=${REL:6}
suffix_lower=$(echo $suffix | tr '[:upper:]' '[:lower:]')
echo "Project to be created : obsidian-$suffix_lower"

echo Press any key to create OpenShift Project and deploy ...
read junk

# Create project
oc new-project obsidian-$suffix_lower
sleep 5

# Deploy the backend
echo "Deploy the backend ..."
oc create -f ./templates/backend-$REL.yml
oc process backend-generator-s2i | oc create -f -
oc start-build backend-generator-s2i

# Deploy the Front
echo "Deploy the frontend ..."
oc create -f templates/front-$REL.yml
oc process front-generator-s2i | oc create -f -
oc start-build front-generator-s2i


{'fraction_non_alphanumeric': 0.1569544164301219, 'fraction_numerical': 0.025546835865753882, 'mean_word_length': 2.250135648399349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 10, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7132274', 'n_tokens_mistral': 2168, 'n_tokens_neox': 1997, 'n_words': 470}