Skip to content

Commit

Permalink
Created formula to create db and updated inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jfurtado1 committed Oct 21, 2021
1 parent 1f6de94 commit ee5fdc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion vkpr/postgres/createdb/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
"label": "Type the db users' password: ",
"name": "dbpassword",
"type": "text"
},
{
"name": "password",
"type": "CREDENTIAL_POSTGRES_PASSWORD"
}
],
"template": "shell-bat",
"templateRelease:": "2.16.2"
}
}
8 changes: 7 additions & 1 deletion vkpr/postgres/createdb/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

runFormula() {
echo "Hello World"
local PG_PASSWORD=$($VKPR_JQ -r '.credential.password' ~/.rit/credentials/default/postgres)
if [[ $(checkPodName "postgres-postgresql") = "true" ]]; then
$VKPR_KUBECTL run init-db --rm -it --restart="Never" --namespace $VKPR_K8S_NAMESPACE --image docker.io/bitnami/postgresql:11.13.0-debian-10-r0 --env="PGUSER=postgres" --env="PGPASSWORD=$PG_PASSWORD" --env="PGHOST=postgres-postgresql" --env="PGPORT=5432" --env="PGDATABASE=postgres" \
--command -- psql -c '\x' -c "CREATE USER $DBUSER WITH ENCRYPTED PASSWORD '$DBPASSWORD';" -c "CREATE DATABASE $DBNAME;" -c "GRANT ALL PRIVILEGES ON DATABASE $DBNAME TO $DBUSER"
else
echoColor "red" "Error, Postgresql doesn't up or installed yet"
fi
}

0 comments on commit ee5fdc4

Please sign in to comment.