|
162 | 162 | "if BUCKET_URI is None or BUCKET_URI.strip() == \"\" or BUCKET_URI == \"gs://\":\n", |
163 | 163 | " BUCKET_URI = f\"gs://{PROJECT_ID}-tmp-{now}-{str(uuid.uuid4())[:4]}\"\n", |
164 | 164 | " BUCKET_NAME = \"/\".join(BUCKET_URI.split(\"/\")[:3])\n", |
165 | | - " ! gcloud storage buckets create --location {REGION} {BUCKET_URI}\n", |
| 165 | + " ! gsutil mb -l {REGION} {BUCKET_URI}\n", |
166 | 166 | "else:\n", |
167 | 167 | " assert BUCKET_URI.startswith(\"gs://\"), \"BUCKET_URI must start with `gs://`.\"\n", |
168 | | - " shell_output = ! gcloud storage ls --full --buckets {BUCKET_NAME} | grep \"Location Constraint:\" | sed \"s/Location Constraint://\"\n", |
| 168 | + " shell_output = ! gsutil ls -Lb {BUCKET_NAME} | grep \"Location constraint:\" | sed \"s/Location constraint://\"\n", |
169 | 169 | " bucket_region = shell_output[0].strip().lower()\n", |
170 | 170 | " if bucket_region != REGION:\n", |
171 | 171 | " raise ValueError(\n", |
|
190 | 190 | "\n", |
191 | 191 | "\n", |
192 | 192 | "# Provision permissions to the SERVICE_ACCOUNT with the GCS bucket\n", |
193 | | - "! gcloud storage buckets add-iam-policy-binding $BUCKET_NAME --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.admin\n", |
| 193 | + "! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.admin $BUCKET_NAME\n", |
194 | 194 | "\n", |
195 | 195 | "! gcloud config set project $PROJECT_ID\n", |
196 | 196 | "! gcloud projects add-iam-policy-binding --no-user-output-enabled {PROJECT_ID} --member=serviceAccount:{SERVICE_ACCOUNT} --role=\"roles/storage.admin\"\n", |
|
911 | 911 | "\n", |
912 | 912 | "delete_bucket = False # @param {type:\"boolean\"}\n", |
913 | 913 | "if delete_bucket:\n", |
914 | | - " ! gcloud storage rm --recursive $BUCKET_NAME" |
| 914 | + " ! gsutil -m rm -r $BUCKET_NAME" |
915 | 915 | ] |
916 | 916 | } |
917 | 917 | ], |
|
0 commit comments