@@ -73,7 +73,9 @@ readonly STAGING_PROJECT_SERVICES=(
73
73
)
74
74
75
75
readonly STAGING_PROJECT_DISABLED_SERVICES=(
76
- # Disabling per https://github.com/kubernetes/k8s.io/issues/1963
76
+ # Disabled per https://github.com/kubernetes/k8s.io/issues/1963
77
+ containeranalysis.googleapis.com
78
+ # Disabled per https://github.com/kubernetes/k8s.io/issues/1963
77
79
containerscanning.googleapis.com
78
80
)
79
81
@@ -143,6 +145,10 @@ function ensure_staging_project() {
143
145
color 6 " Ensuring disabled services for staging project: ${project} "
144
146
ensure_disabled_services " ${project} " " ${STAGING_PROJECT_DISABLED_SERVICES[@]} "
145
147
148
+ # TODO(spiffxp): remove when binding has been removed
149
+ color 6 " Ensuring containeranalysis service agent binding removed for staging project: ${project} "
150
+ ensure_removed_containeranalysis_serviceagent " ${project} "
151
+
146
152
# Enable image promoter access to vulnerability scanning results
147
153
color 6 " Ensuring ${cip_principal} can view vulnernability scanning results for project: ${project} "
148
154
ensure_project_role_binding " ${project} " " ${cip_principal} " " roles/containeranalysis.occurrences.viewer"
@@ -318,6 +324,28 @@ function ensure_staging_gcb_builder_service_account() {
318
324
" ${sa_email} "
319
325
}
320
326
327
+ # Ensures the containeranalysis service agent iam binding has been removed
328
+ # from the given project (as well as any other members that happen to have
329
+ # the service agent role)
330
+ #
331
+ # $1: The project name
332
+ function ensure_removed_containeranalysis_serviceagent() {
333
+ if [ $# != 1 ] || [ -z " $1 " ]; then
334
+ echo " ${FUNCNAME[0]} (project) requires 2 arguments" >&2
335
+ return 1
336
+ fi
337
+ local project=" $1 "
338
+ local role=" roles/containeranalysis.ServiceAgent"
339
+
340
+ gcloud projects get-iam-policy " ${project} " > " ${TMPDIR} /iam.yaml"
341
+ mapfile -t members < <(
342
+ < " ${TMPDIR} /iam.yaml" yq -r " .bindings | map(select(.role==\" ${role} \" ).members) | flatten | .[]"
343
+ )
344
+ for member in " ${members[@]} " ; do
345
+ ensure_removed_project_role_binding " ${project} " " ${member} " " ${role} "
346
+ done
347
+ }
348
+
321
349
#
322
350
# Special cases
323
351
#
0 commit comments