@@ -259,12 +259,11 @@ copy_logs_to_workdir () {
259259}
260260
261261# ##############################################################################
262- # Ensures all registries that will be used during both mock and --nomock
263- # runs allow write access so we don't fall over later
264- # @param registries - A space separated list of registries
262+ # Ensures we have write access to a specified registry
263+ # @param registry - A registry to check the ACLs for
265264#
266265ensure_registry_acls () {
267- local registries=( $1 )
266+ local registry= " $1 "
268267 local emptyfile=" $TMPDIR /empty-file.$$ "
269268 local gs_path
270269 local r
@@ -276,27 +275,29 @@ ensure_registry_acls () {
276275
277276 # Short of creating a hardcoded map of project-id to registry, translating
278277 # _ to - seems to be a simple rule to keep this, well, simple.
279- for r in ${registries[*]// _/ -} ; do
280- # In this context, "google-containers" is still used
281- if [[ " $r " == " $GCRIO_PATH_PROD " ]]; then
282- artifact_namespace=" google-containers"
283- else
284- artifact_namespace=" ${r/ gcr.io\/ / } "
285- fi
278+ r=${registry// _/ -}
286279
287- gs_path=" gs://artifacts.$artifact_namespace .appspot.com/containers"
288- logecho -n " Checking write access to registry $r : "
289- if logrun $GSUTIL -q cp $emptyfile $gs_path && \
290- logrun $GSUTIL -q rm $gs_path /${emptyfile##*/ } ; then
291- logecho $OK
292- else
293- logecho $FAILED
294- (( retcode++ ))
295- fi
280+ # When we are no-mock mode we need to perform an image promotion, so it's
281+ # unnecessary to check for write access to the production container registry.
282+ if (( FLAGS_nomock)) ; then
283+ logecho " Skipping registry ACL check on $GCRIO_PATH_PROD in no-mock mode"
284+ return 0
285+ else
286+ artifact_namespace=" ${r/ gcr.io\/ / } "
287+ fi
296288
297- # Always reset back to $USER
298- (( FLAGS_gcb)) || logrun $GCLOUD config set account $GCP_USER
299- done
289+ gs_path=" gs://artifacts.$artifact_namespace .appspot.com/containers"
290+ logecho -n " Checking write access to registry $r : "
291+ if logrun $GSUTIL -q cp $emptyfile $gs_path && \
292+ logrun $GSUTIL -q rm $gs_path /${emptyfile##*/ } ; then
293+ logecho $OK
294+ else
295+ logecho $FAILED
296+ (( retcode++ ))
297+ fi
298+
299+ # Always reset back to $USER
300+ (( FLAGS_gcb)) || logrun $GCLOUD config set account $GCP_USER
300301
301302 logrun rm -f $emptyfile
302303
@@ -378,7 +379,7 @@ check_prerequisites () {
378379
379380 # Verify write access to all container registries that might be used
380381 # to ensure both mock and --nomock runs will work.
381- ensure_registry_acls " ${ALL_CONTAINER_REGISTRIES[*]} " || return 1
382+ ensure_registry_acls " $GCRIO_PATH " || return 1
382383
383384 logecho -n " Checking cloud project state: "
384385 GCLOUD_PROJECT=$( $GCLOUD config get-value project 2> /dev/null)
0 commit comments