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 20e9922 commit c7cd7e5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
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
@@ -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
22 changes: 22 additions & 0 deletions examples/gsutil/gsutil-example.sh
@@ -0,0 +1,22 @@
#!/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

# 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 an object
gsutil -o "Credentials:gs_json_host=127.0.0.1" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" cp - "gs://${bucket_name}/hello.txt" <<<Hello

# list objects in the bucket (should include the repo that was just created)
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}"

0 comments on commit c7cd7e5

Please sign in to comment.