Created new script and added functions for current layout
@@ -39,6 +39,7 @@ for ARGUMENT in "$@"; do
export "$KEY"="$VALUE"
done
+check_arguments () {
# Check all arguments added to the command
################################################
if test -n "${tag+x}"; then
@@ -70,9 +71,11 @@ fi
echo "Spring profile: $springProfile"
echo "Version tag: $tag"
echo "buildarg supplied: $buildarg"
+}
+secret_generation () {
echo "Start building assets required for container"
-####################################################
+ ##################################################
echo "Generating challenge 12-data"
openssl rand -base64 32 | tr -d '\n' >yourkey.txt
echo "Generating challenge 16-data"
@@ -87,19 +90,26 @@ openssl rand -base64 32 | tr -d '\n' > thirdkey.txt
answer=$(<thirdkey.txt)
answerRegexSafe="$(printf '%s' "$answer" | gsed -e 's/[]\/$*.^|[]/\\&/g' | gsed ':a;N;$!ba;s,\n,\\n,g')"
gsed -i "s/Placeholder Password, find the real one in the history of the container/$answerRegexSafe/g" ../../src/main/resources/.bash_history
+}
+
+check_required_install () {
echo "Check if all required binaries are installed"
##################################################
source ../../scripts/check-available-commands.sh
checkCommandsAvailable java docker mvn git
+}
+build_update_pom () {
echo "Building and updating pom.xml file so we can use it in our docker"
########################################################################
cd ../.. && mvn clean && mvn --batch-mode release:update-versions -DdevelopmentVersion=${tag}-SNAPSHOT && mvn install -DskipTests
cd .github/scripts
docker buildx create --name mybuilder
docker buildx use mybuilder
+}
+create_containers () {
echo "Creating containers"
##########################
if [[ "$springProfile" != "All" ]]; then
@@ -109,7 +119,17 @@ else
docker buildx build -t jeroenwillemsen/wrongsecrets:$tag-local-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=local-vault" --load ./../../.
docker buildx build -t jeroenwillemsen/wrongsecrets:$tag-k8s-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=kubernetes-vault" --load ./../../.
fi
+ }
+ restore_temp_change () {
echo "Restoring temporal change"
git restore ../../js/index.js
git restore ../../pom.xml
+}
+
+check_arguments
+secret_generation
+check_required_install
+build_update_pom
+create_containers
+restore_temp_change
\ No newline at end of file
