Repository navigation
feat(storage): support STORAGE_EMULATOR_HOST environment variable #34023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SalvatoreT
wants to merge
1
commit into
googleapis:main
Choose a base branch
from
SalvatoreT:salvatoret/34022/support-storage-emulator-host
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+253
−15
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| - | ||
| OVERVIEW.md | ||
| AUTHENTICATION.md | ||
| EMULATOR.md | ||
| LOGGING.md | ||
| CONTRIBUTING.md | ||
| TROUBLESHOOTING.md | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Google Cloud Storage Emulator | ||
|
|
||
| To develop and test your application locally, you can point the client at a | ||
| Cloud Storage emulator instead of the live service. | ||
|
|
||
| Set the `STORAGE_EMULATOR_HOST` environment variable to the host and port where | ||
| the emulator is running. You can set it in the shell that runs your Ruby code, | ||
| or in the code itself: | ||
|
|
||
| ```ruby | ||
| require "google/cloud/storage" | ||
|
|
||
| # Make Storage use the emulator | ||
| ENV["STORAGE_EMULATOR_HOST"] = "localhost:4443" | ||
|
|
||
| storage = Google::Cloud::Storage.new | ||
|
|
||
| bucket = storage.create_bucket "my-bucket" | ||
| file = bucket.create_file StringIO.new("Hello world!"), "hello-world.txt" | ||
| file.name #=> "hello-world.txt" | ||
| ``` | ||
|
|
||
| You can also pass the `emulator_host` argument, or set `emulator_host` in the | ||
| configuration: | ||
|
|
||
| ```ruby | ||
| require "google/cloud/storage" | ||
|
|
||
| storage = Google::Cloud::Storage.new emulator_host: "localhost:4443" | ||
|
|
||
| # Or, for every client: | ||
| Google::Cloud::Storage.configure do |config| | ||
| config.emulator_host = "localhost:4443" | ||
| end | ||
| ``` | ||
|
|
||
| When an emulator host is set, the client: | ||
|
|
||
| * Uses `http://` if the host has no scheme. Include the scheme, such as | ||
| `https://localhost:4443`, if the emulator serves HTTPS. | ||
| * Connects anonymously instead of looking up Application Default Credentials. | ||
| Credentials passed with the `credentials` argument are still used. | ||
| * Doesn't require a project ID. | ||
| * Ignores the `endpoint` option. | ||
|
|
||
| `Google::Cloud::Storage.anonymous` also uses the emulator host from the | ||
| environment variable or the configuration. |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.