File tree 2 files changed +12
-3
lines changed
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()
50
50
# Using bash magic to parse JSON for IAM
51
51
# Grepping for a line with client email returning anything quoted after the colon
52
52
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 ' "' )
55
54
readonly GOTTEN_BIND_ROLES=$( gcloud projects get-iam-policy ${PROJECT} --flatten=" bindings[].members" --format=' table(bindings.role)' --filter=" bindings.members:${IAM_NAME} " )
56
55
readonly BIND_ROLES=$( get_needed_roles)
57
56
MISSING_ROLES=false
Original file line number Diff line number Diff line change @@ -25,9 +25,19 @@ ensure_var PROJECT
25
25
ensure_var GCE_PD_SA_NAME
26
26
ensure_var GCE_PD_SA_DIR
27
27
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
+
28
38
readonly KUBEDEPLOY=" ${PKGDIR} /deploy/kubernetes"
29
39
readonly 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"
31
41
32
42
# Check if SA exists
33
43
CREATE_SA=true
You can’t perform that action at this time.
0 commit comments