feat: support STORAGE_EMULATOR_HOST environment variable#34023
Open
SalvatoreT wants to merge 1 commit into
Open
feat: support STORAGE_EMULATOR_HOST environment variable#34023SalvatoreT wants to merge 1 commit into
SalvatoreT wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
9edc261 to
fc95213
Compare
Allow pointing the Storage client at a local emulator via the STORAGE_EMULATOR_HOST environment variable, the emulator_host config field, or an emulator_host keyword argument. When set, the client connects to the emulator anonymously and does not require credentials or a project ID. Fixes googleapis#34022
fc95213 to
0b6a94e
Compare
Author
|
Hey @cpriti-os @aandreassa @bajajneha27 if y'all are open to externally-authored PRs, would one of you be able to review this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for the
STORAGE_EMULATOR_HOSTenvironment variable togoogle-cloud-storage, so the client can be pointed at a local Cloud Storage emulator (e.g.fake-gcs-server, the gcloud storage emulator). This brings the Ruby library in line with the Pythongoogle-cloud-storagelibrary (see googleapis/google-cloud-python#9219) and the existing emulator-aware Ruby gems (pubsub, datastore, firestore, bigtable, bigquery).Fixes #34022
Behavior
The emulator can be selected in three ways (in precedence order):
Google::Cloud::Storage.new emulator_host: "http://localhost:9000"Google::Cloud::Storage.configure { |c| c.emulator_host = "http://localhost:9000" }STORAGE_EMULATOR_HOST=http://localhost:9000environment variableWhen an emulator host is set:
root_url).GOOGLE_CLOUD_PROJECTwhen available).This mirrors the Python client's use of anonymous credentials and an optional project when the emulator is active. Unlike the gRPC-based gems, storage does not use the
:this_channel_is_insecuresentinel, since that is a gRPC concept; the REST equivalent is anonymous (nil) credentials, as already used byGoogle::Cloud::Storage.anonymous.Changes
lib/google-cloud-storage.rb: register theemulator_hostconfig field (defaulting toSTORAGE_EMULATOR_HOST) and threademulator_host:through theGoogle::Cloud.storage/Google::Cloud#storageconvenience methods.lib/google/cloud/storage.rb: add theemulator_host:keyword toStorage.new, connect anonymously to the emulator without requiring credentials or a project, and document the option.test/google/cloud/storage_test.rb: unit tests covering the env var, the keyword argument, the config field, the optional project, and honoring explicitly-provided credentials.Testing
test/google/cloud/storage_test.rb: 22 runs, 303 assertions, 0 failures.🤖 Generated with Claude Code