Skip to content

Commit

Permalink
examples: add example with gsutil
Browse files Browse the repository at this point in the history
Hoping to reproduce #217. Still need to improve the situation with
examples vs integration tests (see #1168).
  • Loading branch information
fsouza committed May 27, 2023
1 parent 96a918e commit b6db6fc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions ci/run-gsutil-example.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions examples/gsutil/gsutil-example.sh
Original file line number Diff line number Diff line change
@@ -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}"
1 change: 1 addition & 0 deletions examples/gsutil/hello.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
Binary file added examples/gsutil/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b6db6fc

Please sign in to comment.