Skip to content

Conversation

@Tchebychev
Copy link

Problem

We are using GitLab with S3NS (Thales' trusted cloud, which offers a Google Cloud Storage-compatible API).
GitLab uses the fog-google gem to interact with Google Cloud Storage buckets.

However, we faced connection issues because fog-google currently 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_url to override the default API root URL.
It also updates Real and Mock classes, as well as Directory and File models, to generate URLs dynamically based on the configured :host, :scheme, and :port instead of using the hardcoded Google domains.

Changes

  • lib/fog/google/storage/storage_json.rb: Added :google_json_root_url to recognized options.
  • lib/fog/google/storage/storage_json/real.rb: Updated initialization to use google_json_root_url if provided, and added a bucket_base_url helper method.
  • lib/fog/google/storage/storage_json/mock.rb: Implemented bucket_base_url for consistency in tests.
  • lib/fog/google/storage/storage_json/models/directory.rb & file.rb: Updated public_url methods to use bucket_base_url.

Configuration Example

To use a custom endpoint (e.g., S3NS), one can now configure fog like this:

connection_options = {
  provider:					'Google',
  google_project:			'my-project',
  google_json_key_string:	'{"my": "json_creds"}',
  google_json_root_url:		'https://s3ns.example.com/storage/v1/', # Points to S3NS API
  host:						's3ns.example.com',
  scheme:					'https',
  port:						443
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant