diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index facd632dee..5760b8757a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -122,6 +122,9 @@ jobs: - lang: python docker-image: python:latest entrypoint: /bin/bash + - lang: gsutil + docker-image: python:latest + entrypoint: /bin/bash - lang: node docker-image: node:14-alpine entrypoint: /bin/sh diff --git a/ci/run-gsutil-example.sh b/ci/run-gsutil-example.sh new file mode 100644 index 0000000000..f4ab69afca --- /dev/null +++ b/ci/run-gsutil-example.sh @@ -0,0 +1,12 @@ +# Copyright 2023 Francisco Souza. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +set -e + +./fake-gcs-server -backend memory -port 4443 & + +pip install gsutil +./examples/gsutil/gsutil-example.sh + +pkill fake-gcs-server diff --git a/examples/gsutil/gsutil-example.sh b/examples/gsutil/gsutil-example.sh new file mode 100755 index 0000000000..6890765376 --- /dev/null +++ b/examples/gsutil/gsutil-example.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Copyright 2023 Francisco Souza. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +set -euo pipefail + +bucket_name=some-bucket +project_id=test-project +here=$(cd "$(dirname "${0}")" && pwd -P) + +# create bucket +gsutil -o "Credentials:gs_json_host=127.0.0.1" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" mb -p "${project_id}" "gs://${bucket_name}" + +# list objects in the bucket (should be empty) +gsutil -o "Credentials:gs_json_host=127.0.0.1" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" ls -p "${project_id}" "gs://${bucket_name}" + +# upload a couple of fileds +gsutil -o "Credentials:gs_json_host=127.0.0.1" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" cp "${here}"/hello.txt "${here}"/image.png "gs://${bucket_name}/" + +# list objects in the bucket (should include the files that were just uploaded) +gsutil -o "Credentials:gs_json_host=127.0.0.1" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" ls -p "${project_id}" "gs://${bucket_name}" diff --git a/examples/gsutil/hello.txt b/examples/gsutil/hello.txt new file mode 100644 index 0000000000..ce01362503 --- /dev/null +++ b/examples/gsutil/hello.txt @@ -0,0 +1 @@ +hello diff --git a/examples/gsutil/image.png b/examples/gsutil/image.png new file mode 100644 index 0000000000..90d7f8241f Binary files /dev/null and b/examples/gsutil/image.png differ