| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ####################################################################################### |
| 3 | # Copyright ETSI Contributors and Others. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 14 | # implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | ####################################################################################### |
| 18 | |
| 19 | set -e |
| 20 | |
| 21 | export HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")") |
| 22 | source "${HERE}/library/functions.sh" |
| 23 | source "${HERE}/library/trap.sh" |
| 24 | |
| 25 | ############################################ |
| 26 | # Main script starts here |
| 27 | ############################################ |
| 28 | |
| 29 | # In case no argument is passed, takes the value of the environment variable |
| 30 | MINIO_TENANT_NAME=${1:-${MINIO_TENANT_NAME}} |
| 31 | |
| 32 | m "\nSaving Minio enviroment to credentials folder..." |
| 33 | |
| 34 | # Loads credentials into environment variables |
| 35 | export MINIO_SA_TOKEN=$(kubectl -n minio-operator get secret console-sa-secret -o jsonpath="{.data.token}" | base64 -d) |
| 36 | export MINIO_OSM_USERNAME=$(kubectl get secret ${MINIO_TENANT_NAME}-user-1 -n ${MINIO_TENANT_NAME} -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d) |
| 37 | export MINIO_OSM_PASSWORD=$(kubectl get secret ${MINIO_TENANT_NAME}-user-1 -n ${MINIO_TENANT_NAME} -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d) |
| 38 | |
| 39 | # Grants that all environment variables are defined |
| 40 | export MINIO_INGRESS_CONSOLE_HOST=${MINIO_INGRESS_CONSOLE_HOST:-""} |
| 41 | export MINIO_INGRESS_TENANT_HOST=${MINIO_INGRESS_TENANT_HOST:-""} |
| 42 | |
| 43 | # Saves locally to local environment at credentials folder |
| 44 | cat << EOF > "${CREDENTIALS_DIR}/minio_environment.rc" |
| 45 | # Minio credentials |
| 46 | export MINIO_SA_TOKEN=${MINIO_SA_TOKEN} |
| 47 | export MINIO_OSM_USERNAME=${MINIO_OSM_USERNAME} |
| 48 | export MINIO_OSM_PASSWORD='${MINIO_OSM_PASSWORD}' |
| 49 | |
| 50 | # Minio Console endpoint(s) |
| 51 | export MINIO_CONSOLE_URL=${MINIO_CONSOLE_URL} |
| 52 | export MINIO_CONSOLE_HOST=${MINIO_CONSOLE_HOST} |
| 53 | export MINIO_INTERNAL_CONSOLE_HOST=${MINIO_INTERNAL_CONSOLE_HOST} |
| 54 | export MINIO_INGRESS_CONSOLE_HOST=${MINIO_INGRESS_CONSOLE_HOST} |
| 55 | export MINIO_CONSOLE_HTTP_PORT=${MINIO_CONSOLE_HTTP_PORT} |
| 56 | export MINIO_CONSOLE_HTTPS_PORT=${MINIO_CONSOLE_HTTPS_PORT} |
| 57 | |
| 58 | # Minio tenant endpoint(s) |
| 59 | export MINIO_TENANT_URL=${MINIO_TENANT_URL} |
| 60 | export MINIO_TENANT_HOST=${MINIO_TENANT_HOST} |
| 61 | export MINIO_INTERNAL_TENANT_HOST=${MINIO_INTERNAL_TENANT_HOST} |
| 62 | export MINIO_INGRESS_TENANT_HOST=${MINIO_INGRESS_TENANT_HOST} |
| 63 | export MINIO_TENANT_HTTPS_PORT=${MINIO_TENANT_HTTPS_PORT} |
| 64 | |
| 65 | # Location of certificate and key for Minio's tenant enpoint |
| 66 | export MINIO_TENANT_TLS_CERT='${MINIO_TENANT_TLS_CERT}' |
| 67 | export MINIO_TENANT_TLS_KEY='${MINIO_TENANT_TLS_KEY}' |
| 68 | EOF |