Skip to content

Commit 26c0367

Browse files
chore: Migrate gsutil usage to gcloud storage (#10002)
1 parent 45e724e commit 26c0367

6 files changed

Lines changed: 17 additions & 18 deletions

File tree

deploy/setup-secret.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function download_existing_key() {
3434
KEY_IDS=$(gcloud iam service-accounts keys list --iam-account=metrics-writer@${METRICS_PROJECT_ID}.iam.gserviceaccount.com --project=${METRICS_PROJECT_ID} --managed-by=user --format="value(name)")
3535
while read -r KEY_ID
3636
do
37-
if gsutil cp gs://${BUCKET_ID}/${KEY_ID}.json ${KEY_FILE}; then
37+
if gcloud storage cp gs://${BUCKET_ID}/${KEY_ID}.json ${KEY_FILE}; then
3838
echo "Downloaded existing key to ${KEY_FILE}"
3939
return 0
4040
fi
@@ -52,8 +52,8 @@ function upload_new_key() {
5252
fi
5353
echo "New service account key created."
5454
KEY_ID=$(gcloud iam service-accounts keys list --iam-account=metrics-writer@${METRICS_PROJECT_ID}.iam.gserviceaccount.com --project=${METRICS_PROJECT_ID} --managed-by=user --format="value(name)" --limit=1)
55-
gsutil cp ${KEY_FILE} gs://${BUCKET_ID}/${KEY_ID}.json
56-
gsutil cp ${KEY_FILE} gs://${BUCKET_ID}/${LATEST_GCS_PATH}
55+
gcloud storage cp ${KEY_FILE} gs://${BUCKET_ID}/${KEY_ID}.json
56+
gcloud storage cp ${KEY_FILE} gs://${BUCKET_ID}/${LATEST_GCS_PATH}
5757
echo "New service account key uploaded to GCS."
5858
return 0
5959
}

hack/update-lts-dependencies.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ HELM_URL=https://get.helm.sh/helm-${HELM_VERSION}-linux-${ARCH}.tar.gz
6868
wget -q -O helm.tar.gz "${HELM_URL}"
6969

7070
# upload the binary to skaffold gcs bucket
71-
gsutil -q cp helm.tar.gz gs://skaffold/deps/helm/helm-${HELM_VERSION}-linux-amd64.tar.gz
71+
gcloud storage cp helm.tar.gz gs://skaffold/deps/helm/helm-${HELM_VERSION}-linux-amd64.tar.gz
7272

7373
# take the shasum and put into correct digests/ dir
7474
sha256sum helm.tar.gz > ${DIGESTS_DIR}/helm.amd64.sha256
@@ -78,7 +78,7 @@ KUSTOMIZE_URL=https://github.com/kubernetes-sigs/kustomize/releases/download/kus
7878
wget -q -O kustomize.tar.gz "${KUSTOMIZE_URL}"
7979

8080
# upload the binary to skaffold gcs bucket
81-
gsutil -q cp kustomize.tar.gz gs://skaffold/deps/kustomize/v${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz
81+
gcloud storage cp kustomize.tar.gz gs://skaffold/deps/kustomize/v${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz
8282

8383
# take the shasum and put into correct digests/ dir
8484
sha256sum kustomize.tar.gz > ${DIGESTS_DIR}/kustomize.amd64.sha256
@@ -88,7 +88,7 @@ KPT_URL=https://github.com/GoogleContainerTools/kpt/releases/download/v${KPT_VER
8888
wget -q -O kpt "${KPT_URL}"
8989

9090
# upload the binary to skaffold gcs bucket
91-
gsutil -q cp kpt gs://skaffold/deps/kpt/v${KPT_VERSION}/kpt_linux_amd64
91+
gcloud storage cp kpt gs://skaffold/deps/kpt/v${KPT_VERSION}/kpt_linux_amd64
9292

9393
# take the shasum and put into correct digests/ dir
9494
sha256sum kpt > ${DIGESTS_DIR}/kpt.amd64.sha256

pkg/skaffold/gcs/gsutil.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
"github.com/GoogleContainerTools/skaffold/v2/proto/v1"
3737
)
3838

39-
const GsutilExec = "gsutil"
39+
const GsutilExec = "gcloud"
4040

4141
type Gsutil interface {
4242
Copy(ctx context.Context, src, dst string, recursive bool) error
@@ -49,11 +49,11 @@ func NewGsutil() Gsutil {
4949
return &gsutil{}
5050
}
5151

52-
// Copy calls `gsutil cp [-r] <source_url> <destination_url>
52+
// Copy calls `gcloud storage cp [--recursive] <source_url> <destination_url>
5353
func (g *gsutil) Copy(ctx context.Context, src, dst string, recursive bool) error {
54-
args := []string{"cp"}
54+
args := []string{"storage", "cp"}
5555
if recursive {
56-
args = append(args, "-r")
56+
args = append(args, "--recursive")
5757
}
5858
args = append(args, src, dst)
5959
cmd := exec.CommandContext(ctx, GsutilExec, args...)

pkg/skaffold/gcs/gsutil_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ func TestCopy(t *testing.T) {
4848
description: "copy single file",
4949
src: file,
5050
dst: gcsFile,
51-
commands: testutil.CmdRunOut(fmt.Sprintf("gsutil cp %s %s", file, gcsFile), "logs"),
51+
commands: testutil.CmdRunOut(fmt.Sprintf("gcloud storage cp %s %s", file, gcsFile), "logs"),
5252
},
5353
{
5454
description: "copy recursively",
5555
src: folder,
5656
dst: gcsFolder,
57-
commands: testutil.CmdRunOut(fmt.Sprintf("gsutil cp -r %s %s", folder, gcsFolder), "logs"),
57+
commands: testutil.CmdRunOut(fmt.Sprintf("gcloud storage cp --recursive %s %s", folder, gcsFolder), "logs"),
5858
recursive: true,
5959
},
6060
{
6161
description: "copy failed",
6262
src: file,
6363
dst: gcsFile,
64-
commands: testutil.CmdRunOutErr(fmt.Sprintf("gsutil cp %s %s", file, gcsFile), "logs", fmt.Errorf("file not found")),
64+
commands: testutil.CmdRunOutErr(fmt.Sprintf("gcloud storage cp %s %s", file, gcsFile), "logs", fmt.Errorf("file not found")),
6565
shouldErr: true,
6666
},
6767
}

vendor/cloud.google.com/go/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/google.golang.org/api/cloudbuild/v1/cloudbuild-api.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)