fog-google 1.28.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95b0e848747f0ed4dd7665ba1523d660f267c7ede2810bfbe30190b53114c3ad
4
- data.tar.gz: 90dfb38e1c8aea6c4b1de0d1aa51d1c99d1f6e815fdf09dd5a1b038ff03285aa
3
+ metadata.gz: 2823e91b65c126736ad10ba861bcbdb0ca74115e6b7fe323f47167810a39b2e4
4
+ data.tar.gz: f72382617a827ecbab25342f02e16447ebc22691cdeead4b08702f6f57cfcd7d
5
5
  SHA512:
6
- metadata.gz: 70382c3cace88299b0680f2af237772be7f52b2635ef2393af6bff26efe2c1bf5fe70d9b47a1e090e497982115908acf8de83ff517ced7e008993f305461dbb9
7
- data.tar.gz: cdb4dfda4e275c2b693a5b370cdb2b4d1171ee0217c90832e243111a56106ff7300856eee404aba46c2047c278600e2a3cc5f6c5b2f80f0a4f0fce5ae5960de6
6
+ metadata.gz: 158e366dd84994ff4bcb71b75c226cc27d93ced775b88ce32985cc037a5de942694d5e487a2febcad280fc440baacd6ddde832cbd8ecd9b1be565c72f1aa5928
7
+ data.tar.gz: db4b3bb11d68344ae3ebde04ef841ce93e8f9590921c42f30932fd9bf968a693e26cf0258da6491e60fbd53b23fe5889fbbbd86c89596f5e8b4329f03f99835e
data/CHANGELOG.md CHANGED
@@ -4,7 +4,13 @@ The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1
4
4
 
5
5
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## 1.27.0
7
+ ## 1.29.0
8
+
9
+ ### User-facing
10
+
11
+ - #652 Replace google_json_root_url with universe_domain
12
+
13
+ ## 1.28.0
8
14
 
9
15
  ### User-facing
10
16
 
@@ -157,12 +157,23 @@ module Fog
157
157
 
158
158
  private
159
159
 
160
+ # Helper method to get universe domain from options or environment
161
+ #
162
+ # @param [Hash] options - client options hash
163
+ # @return [String, nil] - universe domain or nil
164
+ def universe_domain_from_options(options)
165
+ options[:universe_domain] || ENV["GOOGLE_CLOUD_UNIVERSE_DOMAIN"]
166
+ end
167
+
160
168
  # Helper method to process application default authentication
161
169
  #
162
170
  # @param [Hash] options - client options hash
163
171
  # @return [Google::Auth::DefaultCredentials] - google auth object
164
172
  def process_application_default_auth(options)
165
- ::Google::Auth.get_application_default(options[:google_api_scope_url])
173
+ credentials = ::Google::Auth.get_application_default(options[:google_api_scope_url])
174
+ universe_domain = universe_domain_from_options(options)
175
+ credentials.universe_domain = universe_domain if universe_domain && credentials.respond_to?(:universe_domain=)
176
+ credentials
166
177
  end
167
178
 
168
179
  # Helper method to process fallback authentication
@@ -203,10 +214,14 @@ module Fog
203
214
 
204
215
  validate_json_credentials(json_key)
205
216
 
206
- ::Google::Auth::ServiceAccountCredentials.make_creds(
217
+ credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
207
218
  :json_key_io => StringIO.new(json_key),
208
219
  :scope => options[:google_api_scope_url]
209
220
  )
221
+
222
+ universe_domain = universe_domain_from_options(options)
223
+ credentials.universe_domain = universe_domain if universe_domain && credentials.respond_to?(:universe_domain=)
224
+ credentials
210
225
  end
211
226
 
212
227
  # Helper method to sort out deprecated and missing auth options
@@ -8,8 +8,9 @@ module Fog
8
8
  MockClient = Struct.new(:issuer)
9
9
 
10
10
  def initialize(options = {})
11
- shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, GOOGLE_STORAGE_JSON_BASE_URL)
12
11
  @options = options.dup
12
+ api_base_url = storage_api_base_url_for_universe(universe_domain)
13
+ shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, api_base_url)
13
14
  @client = MockClient.new('test')
14
15
  @storage_json = MockClient.new('test')
15
16
  @iam_service = MockClient.new('test')
@@ -20,16 +21,18 @@ module Fog
20
21
  end
21
22
 
22
23
  def bucket_base_url
23
- if @options[:google_json_root_url]
24
- @options[:google_json_root_url]
25
- else
26
- GOOGLE_STORAGE_BUCKET_BASE_URL
27
- end
24
+ storage_base_url_for_universe(universe_domain)
28
25
  end
29
26
 
30
27
  def google_access_id
31
28
  "my-account@project.iam.gserviceaccount"
32
29
  end
30
+
31
+ private
32
+
33
+ def universe_domain
34
+ universe_domain_from_options(@options)
35
+ end
33
36
  end
34
37
  end
35
38
  end
@@ -11,16 +11,16 @@ module Fog
11
11
  attr_reader :storage_json
12
12
 
13
13
  def initialize(options = {})
14
- base_url = options[:google_json_root_url] || GOOGLE_STORAGE_JSON_BASE_URL
15
- shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, base_url)
16
14
  @options = options.dup
15
+ api_base_url = storage_api_base_url_for_universe(universe_domain)
16
+ shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, api_base_url)
17
17
  options[:google_api_scope_url] = GOOGLE_STORAGE_JSON_API_SCOPE_URLS.join(" ")
18
18
 
19
19
  # TODO(temikus): Do we even need this client?
20
20
  @client = initialize_google_client(options)
21
21
 
22
22
  @storage_json = ::Google::Apis::StorageV1::StorageService.new
23
- @storage_json.root_url = base_url if options[:google_json_root_url]
23
+ @storage_json.universe_domain = universe_domain if universe_domain
24
24
  apply_client_options(@storage_json, options)
25
25
 
26
26
  @storage_json.client_options.open_timeout_sec = options[:open_timeout_sec] if options[:open_timeout_sec]
@@ -29,11 +29,7 @@ module Fog
29
29
  end
30
30
 
31
31
  def bucket_base_url
32
- if @options[:google_json_root_url]
33
- @options[:google_json_root_url]
34
- else
35
- GOOGLE_STORAGE_BUCKET_BASE_URL
36
- end
32
+ storage_base_url_for_universe(universe_domain)
37
33
  end
38
34
 
39
35
  def signature(params)
@@ -83,6 +79,10 @@ DATA
83
79
 
84
80
  private
85
81
 
82
+ def universe_domain
83
+ universe_domain_from_options(@options)
84
+ end
85
+
86
86
  def google_access_id
87
87
  @google_access_id ||= get_google_access_id
88
88
  end
@@ -19,6 +19,24 @@ module Fog
19
19
  https_url(params, expires)
20
20
  end
21
21
 
22
+ def storage_api_base_url_for_universe(universe_domain)
23
+ domain = universe_domain.to_s.strip
24
+ if !domain.empty? && domain != "googleapis.com"
25
+ "https://storage.#{domain}/storage/"
26
+ else
27
+ Fog::Google::StorageJSON::GOOGLE_STORAGE_JSON_BASE_URL
28
+ end
29
+ end
30
+
31
+ def storage_base_url_for_universe(universe_domain)
32
+ domain = universe_domain.to_s.strip
33
+ if !domain.empty?
34
+ "https://storage.#{universe_domain}/"
35
+ else
36
+ Fog::Google::StorageJSON::GOOGLE_STORAGE_BUCKET_BASE_URL
37
+ end
38
+ end
39
+
22
40
  private
23
41
 
24
42
  def host_path_query(params, expires)
@@ -17,7 +17,7 @@ module Fog
17
17
  :google_key_string,
18
18
  :google_json_key_location,
19
19
  :google_json_key_string,
20
- :google_json_root_url,
20
+ :universe_domain,
21
21
  :open_timeout_sec,
22
22
  :read_timeout_sec,
23
23
  :send_timeout_sec
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Google
3
- VERSION = "1.28.0".freeze
3
+ VERSION = "1.29.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.28.0
4
+ version: 1.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Welch
@@ -803,7 +803,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
803
803
  - !ruby/object:Gem::Version
804
804
  version: '0'
805
805
  requirements: []
806
- rubygems_version: 3.6.9
806
+ rubygems_version: 3.7.2
807
807
  specification_version: 4
808
808
  summary: Module for the 'fog' gem to support Google.
809
809
  test_files: []