Skip to content

Commit

Permalink
Merge pull request #21770 from chaodaiG/fix-build-cluster-onboard
Browse files Browse the repository at this point in the history
Create-build-cluster script: fix a bug of local var used in another function
  • Loading branch information
k8s-ci-robot authored Apr 12, 2021
2 parents b22bab4 + 1100cd4 commit d5ae4d3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions prow/create-build-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ echo
# generate a JWT kubeconfig file that we can merge into prow's kubeconfig secret so that Prow can schedule pods
function gencreds() {
getClusterCreds
local clusterAlias="build-${TEAM}"
local clusterAlias="$(cluster_alias)"
local outfile="${OUT_FILE}"

cd "${tempdir}"
Expand All @@ -163,7 +163,7 @@ function gencreds() {
# First enable secretmanager API, no op if already enabled
gcloud services enable secretmanager.googleapis.com --project="${PROJECT}"
cd "${origdir}"
local gsm_secret_name="prow_build_cluster_kubeconfig_${clusterAlias}"
local gsm_secret_name="$(gsm_secret_name)"
gcloud secrets create "${gsm_secret_name}" --data-file="$origdir/$outfile" --project="${PROJECT}"
# Grant prow service account access to secretmanager in build cluster
for role in roles/secretmanager.viewer roles/secretmanager.secretAccessor; do
Expand All @@ -178,14 +178,20 @@ function gencreds() {
pause
}


cluster_alias() {
echo "build-${TEAM}"
}
gsm_secret_name() {
echo "prow_build_cluster_kubeconfig_$(cluster_alias)"
}
ensure_kustomize() {
if ! which "kustomize" > /dev/null 2>&1; then
GOBIN=$(pwd)/ GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/v3
fi
}

create_cl() {
local gsm_secret_name="$(gsm_secret_name)"
cd "${ROOT_DIR}"
clone_uri="$(git config --get remote.origin.url)"
fork="$(echo "${clone_uri}" | gsed -e "s;https://github.com/;;" -e "s;git@github.com:;;" -e "s;.git;;")"
Expand Down Expand Up @@ -266,4 +272,4 @@ function cleanup() {
}
trap cleanup EXIT
main "$@"
cleanup
cleanup

0 comments on commit d5ae4d3

Please sign in to comment.