diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index adb0a66e61e2adee7c3c817e689b961a1ed13d8c..c9ec8d6b6047900b0820a7ab181277f15cb9a24c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,6 @@ +include: + - remote: https://open.greenhost.net/openappstack/openappstack/raw/master/.gitlab/ci_templates/kaniko.yml + stages: - build - test @@ -10,6 +13,7 @@ backend: script: - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - /kaniko/executor --context ${CI_PROJECT_DIR}/backend/ --dockerfile ${CI_PROJECT_DIR}/backend/Dockerfile --destination $CI_REGISTRY_IMAGE/backend:${CI_COMMIT_REF_NAME} + extends: .kaniko_build only: changes: - backend/**/* diff --git a/backend/utils/assign-role.sh b/backend/utils/assign-role.bash old mode 100644 new mode 100755 similarity index 61% rename from backend/utils/assign-role.sh rename to backend/utils/assign-role.bash index 6988f3b975fe359862fcceb6e7937dd7ae9d7daa..f782281428875a5158f8273f2d3be5a7839a18df --- a/backend/utils/assign-role.sh +++ b/backend/utils/assign-role.bash @@ -1,23 +1,20 @@ #!/bin/bash +if [[ $1 == "" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]] || [[ $2 == "" ]]; then + echo "usage: $0 USERNAME ROLE [ SERVER ]"; + exit 0; +fi + USERNAME=$1 ROLE=$2 SERVER=$3 -PORT=$4 -if [[ $USERNAME == "" ]] || [[ $ROLE == "" ]]; then - echo "Please specify username and role" - exit 1 -fi if [[ $SERVER == "" ]]; then - SERVER=localhost -fi -if [[ $PORT == "" ]]; then - PORT=5000 + SERVER=http://localhost:5000 fi echo "Assigning role $ROLE to User $USERNAME" curl --header "Content-Type: application/json" \ --request POST \ --data "{\"query\": \"mutation {addRoleToUser(username: \\\"$USERNAME\\\", role: \\\"$ROLE\\\"){user{username, roles{edges{node{name}}}}}}\" }" \ - http://$SERVER:$PORT/graphql + $SERVER/graphql diff --git a/backend/utils/create-application.sh b/backend/utils/create-application.bash old mode 100644 new mode 100755 similarity index 60% rename from backend/utils/create-application.sh rename to backend/utils/create-application.bash index 5249d11aa68027de0c48ae5a9e073ef97b625a55..ad33e5204db559778354f50ab7ac9af46380098d --- a/backend/utils/create-application.sh +++ b/backend/utils/create-application.bash @@ -1,22 +1,19 @@ #!/bin/bash +if [[ $1 == "" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then + echo "usage: $0 APPLICATION [ SERVER ]"; + exit 0; +fi + APPLICATION=$1 SERVER=$2 -PORT=$3 -if [[ $APPLICATION == "" ]]; then - echo "Please specify an application name" - exit 1 -fi if [[ $SERVER == "" ]]; then - SERVER=localhost -fi -if [[ $PORT == "" ]]; then - PORT=5000 + SERVER=http://localhost:5000 fi echo "Creating application $APPLICATION" curl --header "Content-Type: application/json" \ --request POST \ --data "{\"query\": \"mutation {createApplication(name: \\\"$APPLICATION\\\"){application{name}}}\" }" \ - http://$SERVER:$PORT/graphql + $SERVER/graphql diff --git a/backend/utils/create-role.sh b/backend/utils/create-role.bash old mode 100644 new mode 100755 similarity index 58% rename from backend/utils/create-role.sh rename to backend/utils/create-role.bash index 77aa4d09c7ddecd010144d94213532622e106546..15c6209fba6bbf22227206c85d0b7539c42428e9 --- a/backend/utils/create-role.sh +++ b/backend/utils/create-role.bash @@ -1,22 +1,19 @@ #!/bin/bash +if [[ $1 == "" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then + echo "usage: $0 ROLE [ SERVER ]"; + exit 0; +fi + ROLE=$1 SERVER=$2 -PORT=$3 -if [[ $ROLE == "" ]]; then - echo "Please specify a role name" - exit 1 -fi if [[ $SERVER == "" ]]; then - SERVER=localhost -fi -if [[ $PORT == "" ]]; then - PORT=5000 + SERVER=http://localhost:5000 fi echo "Creating role $ROLE" curl --header "Content-Type: application/json" \ --request POST \ --data "{\"query\": \"mutation {createRole(name: \\\"$ROLE\\\"){role{name}}}\" }" \ - http://$SERVER:$PORT/graphql + $SERVER/graphql diff --git a/backend/utils/create-user.sh b/backend/utils/create-user.bash old mode 100644 new mode 100755 similarity index 52% rename from backend/utils/create-user.sh rename to backend/utils/create-user.bash index 2f5e526e0c8d84be556001efd1c216992442d5e4..1b124e40cfb69ef9154d3406995341c9e407b591 --- a/backend/utils/create-user.sh +++ b/backend/utils/create-user.bash @@ -1,24 +1,21 @@ #!/bin/bash +if [[ $1 == "" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]] || [[ $2 == "" ]] || [[ $3 == "" ]]; then + echo "usage: $0 USERNAME PASSWORD EMAIL [ SERVER ]"; + exit 0; +fi + USERNAME=$1 PASSWORD=$2 EMAIL=$3 SERVER=$4 -PORT=$5 -if [[ $USERNAME == "" ]] || [[ $PASSWORD == "" ]] || [[ $EMAIL == "" ]]; then - echo "Please specify username, password and email address" - exit 1 -fi if [[ $SERVER == "" ]]; then - SERVER=localhost -fi -if [[ $PORT == "" ]]; then - PORT=5000 + SERVER=http://localhost:5000 fi -echo "Creating admin user" +echo "Creating user $USERNAME" curl --header "Content-Type: application/json" \ --request POST \ --data "{\"query\": \"mutation {createUser(username: \\\"$USERNAME\\\", password: \\\"$PASSWORD\\\", email: \\\"$EMAIL\\\"){user{username}}}\" }" \ - http://$SERVER:$PORT/graphql + $SERVER/graphql diff --git a/backend/utils/grant-access.sh b/backend/utils/grant-access.bash old mode 100644 new mode 100755 similarity index 64% rename from backend/utils/grant-access.sh rename to backend/utils/grant-access.bash index dce48287cafcf53e80c4fc7eb2ae057aac94dcd7..0c14048b8a52257f00e63958fa1ffc0d31be42ca --- a/backend/utils/grant-access.sh +++ b/backend/utils/grant-access.bash @@ -1,23 +1,20 @@ #!/bin/bash +if [[ $1 == "" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]] || [[ $2 == "" ]]; then + echo "usage: $0 USERNAME APPLICATION [ SERVER ]"; + exit 0; +fi + USERNAME=$1 APPLICATION=$2 SERVER=$3 -PORT=$4 -if [[ $USERNAME == "" ]] || [[ $APPLICATION == "" ]]; then - echo "Please specify username and application" - exit 1 -fi if [[ $SERVER == "" ]]; then - SERVER=localhost -fi -if [[ $PORT == "" ]]; then - PORT=5000 + SERVER=http://localhost:5000 fi echo "Granting access to application $APPLICATION to User $USERNAME" curl --header "Content-Type: application/json" \ --request POST \ --data "{\"query\": \"mutation {addApplicationToUser(username: \\\"$USERNAME\\\", application: \\\"$APPLICATION\\\"){user{username, applications{edges{node{name}}}}}}\" }" \ - http://$SERVER:$PORT/graphql + $SERVER/graphql