-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Migrate gsutil usage to gcloud storage #13721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -30,8 +30,8 @@ wget $IMAGE_URL | |||||
| convert * -pointsize 30 -fill white -stroke black -gravity center -annotate +10+40 "$TEXT" output.png | ||||||
|
|
||||||
| # Create a Google Cloud Storage bucket. | ||||||
| gsutil mb gs://$CS_BUCKET | ||||||
| gcloud storage buckets create gs://$CS_BUCKET | ||||||
|
|
||||||
| # Store the image in the Google Cloud Storage bucket and allow all users | ||||||
| # to read it. | ||||||
| gsutil cp -a public-read output.png gs://$CS_BUCKET/output.png | ||||||
| gcloud storage cp --predefined-acl=public-read output.png gs://$CS_BUCKET/output.png | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a good practice to quote variables in shell scripts to prevent potential issues with word splitting or globbing. While GCS bucket names have a restricted character set that makes issues unlikely in this specific case, adopting this practice improves script robustness and is a good habit, as recommended by tools like ShellCheck and style guides like Google's.
Suggested change
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
gcloud storage buckets createcommand will fail if the bucket already exists. This can happen if the startup script runs again on an instance that was restarted, or if the bucket was created through other means. To make the script more robust and idempotent, consider checking for the bucket's existence before attempting to create it. The suggestion also includes quoting the variable, which is a shell scripting best practice (as recommended by tools like ShellCheck and style guides like Google's) to prevent word splitting and globbing issues.