File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,7 @@ function check_service_account()
5050 # Using bash magic to parse JSON for IAM
5151 # Grepping for a line with client email returning anything quoted after the colon
5252 readonly IAM_NAME=$( grep -Po ' "client_email": *\K"[^"]*"' ${GCE_PD_SA_DIR} /cloud-sa.json | tr -d ' "' )
53- # Grepping anything after the @ tell the first . as the project name
54- readonly PROJECT=$( grep -Po ' .*@\K[^.]+' <<< ${IAM_NAME} )
53+ readonly PROJECT=$( grep -Po ' "project_id": *\K"[^"]*"' ${GCE_PD_SA_DIR} /cloud-sa.json | tr -d ' "' )
5554 readonly GOTTEN_BIND_ROLES=$( gcloud projects get-iam-policy ${PROJECT} --flatten=" bindings[].members" --format=' table(bindings.role)' --filter=" bindings.members:${IAM_NAME} " )
5655 readonly BIND_ROLES=$( get_needed_roles)
5756 MISSING_ROLES=false
Original file line number Diff line number Diff line change @@ -25,9 +25,19 @@ ensure_var PROJECT
2525ensure_var GCE_PD_SA_NAME
2626ensure_var GCE_PD_SA_DIR
2727
28+ # If the project id includes the org name in the format "org-name:project", the
29+ # gCloud api will format the project part of the iam email domain as
30+ # "project.org-name"
31+ if [[ $PROJECT == * " :" * ]]; then
32+ IFS=' :' read -ra SPLIT <<< " $PROJECT"
33+ readonly IAM_PROJECT=" ${SPLIT[1]} .${SPLIT[0]} "
34+ else
35+ readonly IAM_PROJECT=" ${PROJECT} "
36+ fi
37+
2838readonly KUBEDEPLOY=" ${PKGDIR} /deploy/kubernetes"
2939readonly BIND_ROLES=$( get_needed_roles)
30- readonly IAM_NAME=" ${GCE_PD_SA_NAME} @${PROJECT } .iam.gserviceaccount.com"
40+ readonly IAM_NAME=" ${GCE_PD_SA_NAME} @${IAM_PROJECT } .iam.gserviceaccount.com"
3141
3242# Check if SA exists
3343CREATE_SA=true
You can’t perform that action at this time.
0 commit comments