diff --git a/.github/ci/common.sh b/.github/ci/common.sh index 1b4757a67..caa0db941 100755 --- a/.github/ci/common.sh +++ b/.github/ci/common.sh @@ -53,18 +53,20 @@ function release_binary { done cd ${oldPwd} - gsutil cp -a public-read \ + gcloud storage cp \ + --predefined-acl=publicRead \ bazel-bin/src/bootstrap/cloud/crc-binary.tar.gz \ "gs://${bucket}/${name}.tar.gz" # Overwrite cache control as we want changes to run-install.sh and version files to be visible # right away. - gsutil -h "Cache-Control:private, max-age=0, no-transform" \ - cp -a public-read \ + gcloud storage cp \ + --predefined-acl=publicRead \ + --header="Cache-Control:private, max-age=0, no-transform" \ src/bootstrap/cloud/run-install.sh \ "gs://${bucket}/" - # The remaining arguments are version labels. gsutil does not support symlinks, so we use version + # The remaining arguments are version labels. GCS does not support symlinks, so we use version # files instead. local vfile vfile=$(mktemp) @@ -72,8 +74,9 @@ function release_binary { shift 2 # Loop over remianing args in $* and creat alias files. for label; do - gsutil -h "Cache-Control:private, max-age=0, no-transform" \ - cp -a public-read \ + gcloud storage cp \ + --predefined-acl=publicRead \ + --header="Cache-Control:private, max-age=0, no-transform" \ ${vfile} "gs://${bucket}/${label}" done } diff --git a/deploy.sh b/deploy.sh index 4fffcb6b1..39e486ee4 100755 --- a/deploy.sh +++ b/deploy.sh @@ -64,11 +64,11 @@ function update_config_var { value="${3}" config_file="$(mktemp)" - gsutil cp "${cloud_bucket}/config.sh" "${config_file}" 2>/dev/null || return + gcloud storage cp "${cloud_bucket}/config.sh" "${config_file}" 2>/dev/null || return save_variable "${config_file}" "${name}" "${value}" - gsutil mv "${config_file}" "${cloud_bucket}/config.sh" + gcloud storage mv "${config_file}" "${cloud_bucket}/config.sh" } function prepare_source_install { diff --git a/docs/concepts/config.md b/docs/concepts/config.md index cc6246727..1eb2c945e 100644 --- a/docs/concepts/config.md +++ b/docs/concepts/config.md @@ -5,7 +5,7 @@ stored with the project in GCS. One can look at the options with the following command: ```shell -gsutil cat gs://${PROJECT_ID}-cloud-robotics-config/config.sh +gcloud storage cat gs://${PROJECT_ID}-cloud-robotics-config/config.sh ``` The settings contained in the config file are used by terraform to setup the diff --git a/docs/how-to/deploy-from-sources.md b/docs/how-to/deploy-from-sources.md index 556e73252..4749ab1c6 100644 --- a/docs/how-to/deploy-from-sources.md +++ b/docs/how-to/deploy-from-sources.md @@ -66,7 +66,7 @@ and 18.04) Linux. You can verify the settings using: ```shell - gsutil cat gs://[PROJECT_ID]-cloud-robotics-config/config.sh + gcloud storage cat gs://[PROJECT_ID]-cloud-robotics-config/config.sh ``` diff --git a/docs/how-to/using-cloud-storage.md b/docs/how-to/using-cloud-storage.md index acbbd6079..22e49b4c6 100644 --- a/docs/how-to/using-cloud-storage.md +++ b/docs/how-to/using-cloud-storage.md @@ -25,11 +25,11 @@ Normally, to access a private Cloud Storage bucket from a robot, you'd need to m On your workstation, run: ```shell - gsutil mb gs://[BUCKET_NAME] + gcloud storage buckets create gs://[BUCKET_NAME] ``` Replace `[BUCKET_NAME]` with the name of the bucket you created, e.g., `robot-hello-world-dc1bb474`. - `gsutil` is the command line tool for accessing Cloud Storage, it is part of the `gcloud-sdk` package; `mb` stands for "make bucket". + `gcloud storage` contains the sub-commands for accessing Cloud Storage, it is part of the `gcloud-sdk` package. Note that the bucket is not publicly writable, as can be verified in the [Cloud Storage browser](https://console.cloud.google.com/storage/browser). @@ -56,7 +56,7 @@ Normally, to access a private Cloud Storage bucket from a robot, you'd need to m On your workstation, run: ```shell - gsutil cat gs://[BUCKET_NAME]/hello_world.txt + gcloud storage cat gs://[BUCKET_NAME]/hello_world.txt ``` This should result in the output `Hello, I am a robot!`. diff --git a/scripts/include-config.sh b/scripts/include-config.sh index 3feabf378..67c63afd1 100755 --- a/scripts/include-config.sh +++ b/scripts/include-config.sh @@ -41,7 +41,7 @@ function check_var_is_one_of { function include_config { local project="$1" - source <(gsutil cat "gs://${project}-cloud-robotics-config/config.sh") + source <(gcloud storage cat "gs://${project}-cloud-robotics-config/config.sh") # Check that config defines the following set of configuration variables check_vars_not_empty GCP_PROJECT_ID GCP_REGION GCP_ZONE diff --git a/scripts/set-config.sh b/scripts/set-config.sh index c559bcff6..dba2eacad 100755 --- a/scripts/set-config.sh +++ b/scripts/set-config.sh @@ -117,7 +117,7 @@ CLOUD_BUCKET="gs://${GCP_PROJECT_ID}-cloud-robotics-config" CONFIG_FILE="$(mktemp)" trap '{ rm -f ${CONFIG_FILE}; }' EXIT -if gsutil cp "${CLOUD_BUCKET}/config.sh" "${CONFIG_FILE}" 2>/dev/null; then +if gcloud storage cp "${CLOUD_BUCKET}/config.sh" "${CONFIG_FILE}" 2>/dev/null; then if [[ -n "${FLAG_ENSURE_CONFIG}" ]]; then echo "Found Cloud Robotics config." exit 0 @@ -288,7 +288,7 @@ if [[ -n "${OLD_TERRAFORM_GCS_BUCKET}" &&\ ! "${OLD_TERRAFORM_GCS_PREFIX}" = "${TERRAFORM_GCS_PREFIX}") ]]; then # Copy Terraform state to new location. echo "Copying Terraform state..." - gsutil cp "gs://${OLD_TERRAFORM_GCS_BUCKET}/${OLD_TERRAFORM_GCS_PREFIX}/*.tfstate" \ + gcloud storage cp "gs://${OLD_TERRAFORM_GCS_BUCKET}/${OLD_TERRAFORM_GCS_PREFIX}/*.tfstate" \ "gs://${TERRAFORM_GCS_BUCKET}/${TERRAFORM_GCS_PREFIX}/" fi @@ -318,7 +318,7 @@ save_variable "${CONFIG_FILE}" CLOUD_ROBOTICS_CERTIFICATE_SUBJECT_COMMON_NAME "$ save_variable "${CONFIG_FILE}" CLOUD_ROBOTICS_CERTIFICATE_SUBJECT_ORGANIZATIONAL_UNIT "${CLOUD_ROBOTICS_CERTIFICATE_SUBJECT_ORGANIZATIONAL_UNIT}" # Upload config to the cloud. -if ! gsutil ls -p ${GCP_PROJECT_ID} | grep "^${CLOUD_BUCKET}/$" >/dev/null; then - gsutil mb -p ${GCP_PROJECT_ID} ${CLOUD_BUCKET} +if ! gcloud -q storage buckets describe --project ${GCP_PROJECT_ID} "${CLOUD_BUCKET}" >/dev/null 2>&1; then + gcloud storage buckets create --project ${GCP_PROJECT_ID} ${CLOUD_BUCKET} fi -gsutil mv "${CONFIG_FILE}" "${CLOUD_BUCKET}/config.sh" +gcloud storage mv "${CONFIG_FILE}" "${CLOUD_BUCKET}/config.sh"