Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/ci/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,30 @@ 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)
echo "${name}.tar.gz" >${vfile}
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
}
Expand Down
4 changes: 2 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/deploy-from-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```


Expand Down
6 changes: 3 additions & 3 deletions docs/how-to/using-cloud-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand All @@ -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!`.
Expand Down
2 changes: 1 addition & 1 deletion scripts/include-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions scripts/set-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"
Loading