Skip to content

Commit 441bad0

Browse files
authored
Merge pull request #533 from CecileRobertMichon/conformance-creds-regexp
Change prow creds parsing to allow no new lines
2 parents 47ebb3a + 4dc1978 commit 441bad0

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

hack/create-dev-cluster.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ set -o errexit
1717
set -o nounset
1818
set -o pipefail
1919

20-
# for Prow we use the provided AZURE_CREDENTIALS file
21-
if [[ -n "${AZURE_CREDENTIALS:-}" ]]; then
22-
export AZURE_SUBSCRIPTION_ID="$(cat ${AZURE_CREDENTIALS} | grep SubscriptionID | cut -d '=' -f 2)"
23-
export AZURE_TENANT_ID="$(cat ${AZURE_CREDENTIALS} | grep TenantID | cut -d '=' -f 2)"
24-
export AZURE_CLIENT_ID="$(cat ${AZURE_CREDENTIALS} | grep ClientID | cut -d '=' -f 2)"
25-
# password might contain an '=' sign so we need to get all the fields after the first '='
26-
export AZURE_CLIENT_SECRET="$(cat ${AZURE_CREDENTIALS} | grep ClientSecret | cut -d '=' -f 2-)"
27-
fi
28-
2920
# Verify the required Environment Variables are present.
3021
: "${AZURE_SUBSCRIPTION_ID:?Environment variable empty or not defined.}"
3122
: "${AZURE_TENANT_ID:?Environment variable empty or not defined.}"

hack/parse-prow-creds.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
20+
parse_cred() {
21+
grep -E -o "$1[[:blank:]]*=[[:blank:]]*\"[^[:space:]\"]+\"" | cut -d '"' -f 2
22+
}
23+
24+
# for Prow we use the provided AZURE_CREDENTIALS file.
25+
# the file is expected to be in toml format.
26+
if [[ -n "${AZURE_CREDENTIALS:-}" ]]; then
27+
export AZURE_SUBSCRIPTION_ID="$(cat ${AZURE_CREDENTIALS} | parse_cred SubscriptionID)"
28+
export AZURE_TENANT_ID="$(cat ${AZURE_CREDENTIALS} | parse_cred TenantID)"
29+
export AZURE_CLIENT_ID="$(cat ${AZURE_CREDENTIALS} | parse_cred ClientID)"
30+
export AZURE_CLIENT_SECRET="$(cat ${AZURE_CREDENTIALS} | parse_cred ClientSecret)"
31+
fi

scripts/ci-conformance.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ source "${REPO_ROOT}/hack/ensure-kind.sh"
3333
source "${REPO_ROOT}/hack/ensure-kubectl.sh"
3434
# shellcheck source=../hack/ensure-kustomize.sh
3535
source "${REPO_ROOT}/hack/ensure-kustomize.sh"
36+
# shellcheck source=../hack/parse-prow-creds.sh
37+
source "${REPO_ROOT}/hack/parse-prow-creds.sh"
3638

3739
random-string() {
3840
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1

0 commit comments

Comments
 (0)