feat: add support for custom storage JSON endpoint #650
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.
Problem
We are using GitLab with S3NS (Thales' trusted cloud, which offers a Google Cloud Storage-compatible API).
GitLab uses the
fog-googlegem to interact with Google Cloud Storage buckets.However, we faced connection issues because
fog-googlecurrently hardcodes the Google Cloud Storage API endpoint (https://www.googleapis.com/storage/) and the public bucket URL (https://storage.googleapis.com/).It was not possible to redirect these calls to the S3NS endpoint via configuration, making it impossible to use
fog-google(and thus GitLab) with S3NS or other GCS-compatible sovereign cloud providers.Solution
This PR introduces support for configuring a custom API endpoint and respecting the host configuration for public URLs.
It adds a new configuration option
:google_json_root_urlto override the default API root URL.It also updates
RealandMockclasses, as well asDirectoryandFilemodels, to generate URLs dynamically based on the configured:host,:scheme, and:portinstead of using the hardcoded Google domains.Changes
lib/fog/google/storage/storage_json.rb: Added:google_json_root_urlto recognized options.lib/fog/google/storage/storage_json/real.rb: Updated initialization to usegoogle_json_root_urlif provided, and added abucket_base_urlhelper method.lib/fog/google/storage/storage_json/mock.rb: Implementedbucket_base_urlfor consistency in tests.lib/fog/google/storage/storage_json/models/directory.rb&file.rb: Updatedpublic_urlmethods to usebucket_base_url.Configuration Example
To use a custom endpoint (e.g., S3NS), one can now configure fog like this: