blob: 95241062cc885658a2adffff60b97a30ce6f9bde [file] [log] [blame]
garciadeblas8d8cd992024-05-21 16:04:14 +02001#!/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
19set -e
20
21export HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")")
22source "${HERE}/library/functions.sh"
23source "${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
30MINIO_TENANT_NAME=${1:-${MINIO_TENANT_NAME}}
31
32m "\nSaving Minio enviroment to credentials folder..."
33
34# Loads credentials into environment variables
35export MINIO_SA_TOKEN=$(kubectl -n minio-operator get secret console-sa-secret -o jsonpath="{.data.token}" | base64 -d)
36export MINIO_OSM_USERNAME=$(kubectl get secret ${MINIO_TENANT_NAME}-user-1 -n ${MINIO_TENANT_NAME} -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d)
37export 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
40export MINIO_INGRESS_CONSOLE_HOST=${MINIO_INGRESS_CONSOLE_HOST:-""}
41export MINIO_INGRESS_TENANT_HOST=${MINIO_INGRESS_TENANT_HOST:-""}
42
43# Saves locally to local environment at credentials folder
44cat << EOF > "${CREDENTIALS_DIR}/minio_environment.rc"
45# Minio credentials
46export MINIO_SA_TOKEN=${MINIO_SA_TOKEN}
47export MINIO_OSM_USERNAME=${MINIO_OSM_USERNAME}
48export MINIO_OSM_PASSWORD='${MINIO_OSM_PASSWORD}'
49
50# Minio Console endpoint(s)
51export MINIO_CONSOLE_URL=${MINIO_CONSOLE_URL}
52export MINIO_CONSOLE_HOST=${MINIO_CONSOLE_HOST}
53export MINIO_INTERNAL_CONSOLE_HOST=${MINIO_INTERNAL_CONSOLE_HOST}
54export MINIO_INGRESS_CONSOLE_HOST=${MINIO_INGRESS_CONSOLE_HOST}
55export MINIO_CONSOLE_HTTP_PORT=${MINIO_CONSOLE_HTTP_PORT}
56export MINIO_CONSOLE_HTTPS_PORT=${MINIO_CONSOLE_HTTPS_PORT}
57
58# Minio tenant endpoint(s)
59export MINIO_TENANT_URL=${MINIO_TENANT_URL}
60export MINIO_TENANT_HOST=${MINIO_TENANT_HOST}
61export MINIO_INTERNAL_TENANT_HOST=${MINIO_INTERNAL_TENANT_HOST}
62export MINIO_INGRESS_TENANT_HOST=${MINIO_INGRESS_TENANT_HOST}
63export MINIO_TENANT_HTTPS_PORT=${MINIO_TENANT_HTTPS_PORT}
64
65# Location of certificate and key for Minio's tenant enpoint
66export MINIO_TENANT_TLS_CERT='${MINIO_TENANT_TLS_CERT}'
67export MINIO_TENANT_TLS_KEY='${MINIO_TENANT_TLS_KEY}'
68EOF