sigs.k8s.io/cluster-api-provider-azure@v1.14.3/hack/parse-prow-creds.sh (about) 1 #!/bin/bash 2 # Copyright 2020 The Kubernetes Authors. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -o errexit 17 set -o nounset 18 set -o pipefail 19 set +o xtrace 20 21 parse_cred() { 22 grep -E -o "\b$1[[:blank:]]*=[[:blank:]]*\"[^[:space:]\"]+\"" | cut -d '"' -f 2 23 } 24 25 # for Prow we use the provided AZURE_CREDENTIALS file. 26 # the file is expected to be in toml format. 27 if [[ -n "${AZURE_CREDENTIALS:-}" ]]; then 28 AZURE_SUBSCRIPTION_ID="$(parse_cred SubscriptionID < "${AZURE_CREDENTIALS}")" 29 AZURE_TENANT_ID="$(parse_cred TenantID < "${AZURE_CREDENTIALS}")" 30 AZURE_CLIENT_ID="$(parse_cred ClientID < "${AZURE_CREDENTIALS}")" 31 AZURE_CLIENT_SECRET="$(parse_cred ClientSecret < "${AZURE_CREDENTIALS}")" 32 AZURE_STORAGE_ACCOUNT="$(parse_cred StorageAccountName < "${AZURE_CREDENTIALS}")" 33 AZURE_STORAGE_KEY="$(parse_cred StorageAccountKey < "${AZURE_CREDENTIALS}")" 34 35 export AZURE_SUBSCRIPTION_ID AZURE_TENANT_ID AZURE_CLIENT_ID AZURE_CLIENT_SECRET AZURE_STORAGE_ACCOUNT AZURE_STORAGE_KEY 36 fi