diff --git a/bin/_config.sh b/bin/_config.sh index 455c3b62..19017bb3 100644 --- a/bin/_config.sh +++ b/bin/_config.sh @@ -5,7 +5,6 @@ set -eo pipefail REPO_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd)" UNSET_USER=0 -TERRAFORM_DIRECTORY="./env.d/terraform" COMPOSE_FILE="${REPO_DIR}/docker-compose.yml" COMPOSE_PROJECT="meet" @@ -92,66 +91,3 @@ function _dc_exec() { function _django_manage() { _dc_run "app-dev" python manage.py "$@" } - -# _set_openstack_project: select an OpenStack project from the openrc files defined in the -# terraform directory. -# -# usage: _set_openstack_project -# -# If necessary the script will prompt the user to choose a project from those available -function _set_openstack_project() { - - declare prompt - declare -a projects - declare -i default=1 - declare -i choice=0 - declare -i n_projects - - # List projects by looking in the "./env.d/terraform" directory - # and store them in an array - read -r -a projects <<< "$( - find "${TERRAFORM_DIRECTORY}" -maxdepth 1 -mindepth 1 -type d | - sed 's|'"${TERRAFORM_DIRECTORY}\/"'||' | - xargs - )" - nb_projects=${#projects[@]} - - if [[ ${nb_projects} -le 0 ]]; then - echo "There are no OpenStack projects defined..." >&2 - echo "To add one, create a subdirectory in \"${TERRAFORM_DIRECTORY}\" with the name" \ - "of your project and copy your \"openrc.sh\" file into it." >&2 - exit 10 - fi - - if [[ ${nb_projects} -gt 1 ]]; then - prompt="Select an OpenStack project to target:\\n" - for (( i=0; i&2 echo "Invalid choice ${choice} (should be <= ${nb_projects})") - exit 11 - fi - - if [[ ${choice} -le 0 ]]; then - choice=${default} - fi - fi - - project=${projects[$((choice-1))]} - # Check that the openrc.sh file exists for this project - if [ ! -f "${TERRAFORM_DIRECTORY}/${project}/openrc.sh" ]; then - (>&2 echo "Missing \"openrc.sh\" file in \"${TERRAFORM_DIRECTORY}/${project}\". Check documentation.") - exit 12 - fi - - echo "${project}" -} diff --git a/bin/state b/bin/state deleted file mode 100755 index 81883853..00000000 --- a/bin/state +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -source "$(dirname "${BASH_SOURCE[0]}")/_config.sh" - -project=$(_set_openstack_project) -echo "Using \"${project}\" project..." - -source "${TERRAFORM_DIRECTORY}/${project}/openrc.sh" - -# Run Terraform commands in the Hashicorp docker container via docker compose -# shellcheck disable=SC2068 -DOCKER_USER="$(id -u):$(id -g)" \ - PROJECT="${project}" \ - docker compose run --rm \ - -e OS_AUTH_URL \ - -e OS_IDENTITY_API_VERSION \ - -e OS_USER_DOMAIN_NAME \ - -e OS_PROJECT_DOMAIN_NAME \ - -e OS_TENANT_ID \ - -e OS_TENANT_NAME \ - -e OS_USERNAME \ - -e OS_PASSWORD \ - -e OS_REGION_NAME \ - terraform-state "$@" diff --git a/bin/terraform b/bin/terraform deleted file mode 100755 index a871a0c6..00000000 --- a/bin/terraform +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -source "$(dirname "${BASH_SOURCE[0]}")/_config.sh" - -project=$(_set_openstack_project) -echo "Using \"${project}\" project..." - -source "${TERRAFORM_DIRECTORY}/${project}/openrc.sh" - -# Run Terraform commands in the Hashicorp docker container via docker compose -# shellcheck disable=SC2068 -DOCKER_USER="$(id -u):$(id -g)" \ - PROJECT="${project}" \ - docker compose run --rm \ - -e OS_AUTH_URL \ - -e OS_IDENTITY_API_VERSION \ - -e OS_USER_DOMAIN_NAME \ - -e OS_PROJECT_DOMAIN_NAME \ - -e OS_TENANT_ID \ - -e OS_TENANT_NAME \ - -e OS_USERNAME \ - -e OS_PASSWORD \ - -e OS_REGION_NAME \ - -e TF_VAR_user_name \ - terraform "$@"