From b6db6fcd0739404cec7429fa23db19b078e51ba3 Mon Sep 17 00:00:00 2001 From: francisco souza <108725+fsouza@users.noreply.github.com> Date: Sat, 27 May 2023 10:55:07 -0400 Subject: [PATCH] examples: add example with gsutil Hoping to reproduce #217. Still need to improve the situation with examples vs integration tests (see #1168). --- .github/workflows/main.yml | 3 +++ ci/run-gsutil-example.sh | 12 ++++++++++++ examples/gsutil/gsutil-example.sh | 23 +++++++++++++++++++++++ examples/gsutil/hello.txt | 1 + examples/gsutil/image.png | Bin 0 -> 1569 bytes 5 files changed, 39 insertions(+) create mode 100644 ci/run-gsutil-example.sh create mode 100755 examples/gsutil/gsutil-example.sh create mode 100644 examples/gsutil/hello.txt create mode 100644 examples/gsutil/image.png 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 0000000000000000000000000000000000000000..90d7f8241febb4169d5e49635bfb7537c02f85d7 GIT binary patch literal 1569 zcmeAS@N?(olHy`uVBq!ia0y~yU|a&i985rwk9x2J+n&VPatG3P-j};9JnyB&_m`YCT2;^#k97Qg zYiRp$QcQ9qUCI<%#VVnaux0($YhTzJrWbFbL%|94