fog-google 1.26.0 → 1.28.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: f5f068b5166ef1e1c12d9bef6ae6da15c489df03929d86047709ef19c3dd70e9
4
- data.tar.gz: 4e94f5cfb3be3fec06535efd74368720b42c37537ea8ffcf2c42888b68bcf283
3
+ metadata.gz: 95b0e848747f0ed4dd7665ba1523d660f267c7ede2810bfbe30190b53114c3ad
4
+ data.tar.gz: 90dfb38e1c8aea6c4b1de0d1aa51d1c99d1f6e815fdf09dd5a1b038ff03285aa
5
5
  SHA512:
6
- metadata.gz: 7fed398133b6232a92ada212c143d65228dbb3a0d6c49b1842256ef79b1fea2a2bf9add46947459d2afb4b3df4f69fb74b49bfe14f0a6459cceab7adb4518ae1
7
- data.tar.gz: 53397624bfcdb357853bba55725c9c60336c734fe0ecb81f812cabed0945cb9009b93b2d3b6ff04e3673082ebee82d1fdda647f55631dced3f27673a8f6f1430
6
+ metadata.gz: 70382c3cace88299b0680f2af237772be7f52b2635ef2393af6bff26efe2c1bf5fe70d9b47a1e090e497982115908acf8de83ff517ced7e008993f305461dbb9
7
+ data.tar.gz: cdb4dfda4e275c2b693a5b370cdb2b4d1171ee0217c90832e243111a56106ff7300856eee404aba46c2047c278600e2a3cc5f6c5b2f80f0a4f0fce5ae5960de6
@@ -36,13 +36,13 @@ jobs:
36
36
  runs-on: fog-arc-runner
37
37
  strategy:
38
38
  matrix:
39
- ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4' ]
39
+ ruby-version: [ '3.1', '3.2', '3.3', '3.4', '4.0' ]
40
40
  # Integration tests from the same task cannot run in parallel yet due to cleanup
41
41
  # TODO(fog-google#626): remove this once cleanup is fixed
42
42
  max-parallel: 1
43
43
 
44
44
  steps:
45
- - uses: actions/checkout@v5
45
+ - uses: actions/checkout@v6
46
46
  - name: Set up Ruby
47
47
  uses: ruby/setup-ruby@v1
48
48
  with:
@@ -37,12 +37,12 @@ jobs:
37
37
  runs-on: fog-arc-runner
38
38
  strategy:
39
39
  matrix:
40
- ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4' ]
40
+ ruby-version: [ '3.1', '3.2', '3.3', '3.4', '4.0' ]
41
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
42
42
  max-parallel: 1
43
43
 
44
44
  steps:
45
- - uses: actions/checkout@v5
45
+ - uses: actions/checkout@v6
46
46
  - name: Set up Ruby
47
47
  uses: ruby/setup-ruby@v1
48
48
  with:
@@ -37,12 +37,12 @@ jobs:
37
37
  runs-on: fog-arc-runner
38
38
  strategy:
39
39
  matrix:
40
- ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4' ]
40
+ ruby-version: [ '3.1', '3.2', '3.3', '3.4', '4.0' ]
41
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
42
42
  max-parallel: 1
43
43
 
44
44
  steps:
45
- - uses: actions/checkout@v5
45
+ - uses: actions/checkout@v6
46
46
  - name: Set up Ruby
47
47
  uses: ruby/setup-ruby@v1
48
48
  with:
@@ -36,12 +36,12 @@ jobs:
36
36
  runs-on: fog-arc-runner
37
37
  strategy:
38
38
  matrix:
39
- ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4' ]
39
+ ruby-version: [ '3.1', '3.2', '3.3', '3.4', '4.0' ]
40
40
  # Integration tests from the same task cannot run in parallel yet due to cleanup
41
41
  max-parallel: 1
42
42
 
43
43
  steps:
44
- - uses: actions/checkout@v5
44
+ - uses: actions/checkout@v6
45
45
  - name: Set up Ruby
46
46
  uses: ruby/setup-ruby@v1
47
47
  with:
@@ -37,12 +37,12 @@ jobs:
37
37
  runs-on: fog-arc-runner
38
38
  strategy:
39
39
  matrix:
40
- ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4' ]
40
+ ruby-version: [ '3.1', '3.2', '3.3', '3.4', '4.0' ]
41
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
42
42
  max-parallel: 1
43
43
 
44
44
  steps:
45
- - uses: actions/checkout@v5
45
+ - uses: actions/checkout@v6
46
46
  - name: Set up Ruby
47
47
  uses: ruby/setup-ruby@v1
48
48
  with:
@@ -37,12 +37,12 @@ jobs:
37
37
  runs-on: fog-arc-runner
38
38
  strategy:
39
39
  matrix:
40
- ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4' ]
40
+ ruby-version: [ '3.1', '3.2', '3.3', '3.4', '4.0' ]
41
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
42
42
  max-parallel: 1
43
43
 
44
44
  steps:
45
- - uses: actions/checkout@v5
45
+ - uses: actions/checkout@v6
46
46
  - name: Set up Ruby
47
47
  uses: ruby/setup-ruby@v1
48
48
  with:
@@ -37,12 +37,12 @@ jobs:
37
37
  runs-on: fog-arc-runner
38
38
  strategy:
39
39
  matrix:
40
- ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4' ]
40
+ ruby-version: [ '3.1', '3.2', '3.3', '3.4', '4.0' ]
41
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
42
42
  max-parallel: 1
43
43
 
44
44
  steps:
45
- - uses: actions/checkout@v5
45
+ - uses: actions/checkout@v6
46
46
  - name: Set up Ruby
47
47
  uses: ruby/setup-ruby@v1
48
48
  with:
@@ -38,12 +38,12 @@ jobs:
38
38
  runs-on: fog-arc-runner
39
39
  strategy:
40
40
  matrix:
41
- ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4' ]
41
+ ruby-version: [ '3.1', '3.2', '3.3', '3.4', '4.0' ]
42
42
  # Integration tests from the same task cannot run in parallel yet due to cleanup
43
43
  max-parallel: 1
44
44
 
45
45
  steps:
46
- - uses: actions/checkout@v5
46
+ - uses: actions/checkout@v6
47
47
  - name: Set up Ruby
48
48
  uses: ruby/setup-ruby@v1
49
49
  with:
@@ -16,10 +16,10 @@ jobs:
16
16
  runs-on: ubuntu-latest
17
17
  strategy:
18
18
  matrix:
19
- ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4', 'head', 'truffleruby-head']
19
+ ruby-version: [ '3.1', '3.2', '3.3', '3.4', '4.0', 'head', 'truffleruby-head']
20
20
 
21
21
  steps:
22
- - uses: actions/checkout@v5
22
+ - uses: actions/checkout@v6
23
23
  - name: Set up Ruby
24
24
  uses: ruby/setup-ruby@v1
25
25
  with:
data/CHANGELOG.md CHANGED
@@ -4,6 +4,29 @@ 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
8
+
9
+ ### User-facing
10
+
11
+ - #650 add support for custom storage endpoints
12
+
13
+ ### Fixed
14
+
15
+ ### Development changes
16
+
17
+ ## 1.27.0
18
+
19
+ ### User-facing
20
+
21
+ ### Fixed
22
+
23
+ - #648 raise exception if disk quota exceeded [rchekaluk]
24
+
25
+ ### Development changes
26
+
27
+ - #647 bump actions/checkout from 5 to 6 [dependabot]
28
+ - #649 bump pry from = 0.15.2 to = 0.16.0 [dependabot]
29
+
7
30
  ## 1.26.0
8
31
 
9
32
  ### User-facing
data/fog-google.gemspec CHANGED
@@ -38,12 +38,13 @@ Gem::Specification.new do |spec|
38
38
  # Debugger
39
39
  # Locked because pry-byebug is broken with 13+
40
40
  # see: https://github.com/deivid-rodriguez/pry-byebug/issues/343
41
- spec.add_development_dependency "pry", "= 0.15.2"
41
+ spec.add_development_dependency "pry", "= 0.16.0"
42
42
 
43
43
  # Testing gems
44
44
  spec.add_development_dependency "retriable"
45
45
  spec.add_development_dependency "rake"
46
46
  spec.add_development_dependency "minitest"
47
+ spec.add_development_dependency "minitest-mock"
47
48
  spec.add_development_dependency "minitest-reporters"
48
49
  spec.add_development_dependency "shindo"
49
50
  spec.add_development_dependency "vcr"
@@ -55,6 +55,17 @@ module Fog
55
55
  operation = Fog::Google::Compute::Operations.new(service: service)
56
56
  .get(data.name, data.zone)
57
57
  operation.wait_for { ready? }
58
+
59
+ # Handle errors
60
+ if operation.error?
61
+ msg = "Error creating disk #{name} size #{size_gb}."
62
+
63
+ err = operation.primary_error
64
+ msg = "#{msg} #{err.message_pretty}" unless err.nil?
65
+
66
+ raise Fog::Errors::Error.new(msg)
67
+ end
68
+
58
69
  reload
59
70
  end
60
71
 
@@ -26,6 +26,82 @@ module Fog
26
26
  attribute :warnings
27
27
  attribute :zone
28
28
 
29
+
30
+ # {:errors=>
31
+ # [{:code=>"QUOTA_EXCEEDED",
32
+ # :error_details=>
33
+ # [{:quota_info=>
34
+ # {:dimensions=>{:region=>"us-east4"},
35
+ # :limit=>500,
36
+ # :limit_name=>"SSD-TOTAL-GB-per-project-region",
37
+ # :metric_name=>"compute.googleapis.com/ssd_total_storage"}}],
38
+ # :message=>"Quota 'SSD_TOTAL_GB' exceeded. Limit: 500.0 in region us-east4."}
39
+ # ]
40
+ # }
41
+ class ErrorInfo
42
+ attr_accessor :code
43
+ attr_accessor :error_details
44
+ attr_accessor :location
45
+ attr_accessor :message
46
+
47
+ def initialize(attributes = {})
48
+ @code = attributes[:code]
49
+ @error_details = attributes[:error_details]
50
+ @location = attributes[:location]
51
+ @message = attributes[:message]
52
+ end
53
+
54
+ def message_pretty
55
+ message
56
+ end
57
+ end # ErrorInfo
58
+
59
+ class QuotaInfo < ErrorInfo
60
+ def initialize(attributes = {})
61
+ code = attributes[:code]
62
+ raise Fog::Errors::Error.new("Invalid error code: #{code}") if code != "QUOTA_EXCEEDED"
63
+
64
+ super(attributes)
65
+ end
66
+
67
+ def quota_infos
68
+ return [] unless error_details.is_a?(Array)
69
+
70
+ error_details_quota_infos = error_details.select{|ed| ed.is_a?(Hash) && ed.has_key?(:quota_info)}
71
+ error_details_quota_infos.map{|ed| ed[:quota_info]}
72
+ end
73
+
74
+ def message_pretty
75
+ msg = super.gsub(/\s*Limit.*region.*[^.]+./, "")
76
+
77
+ quota_infos.each do |qi|
78
+ dimensions = qi[:dimensions] if qi.is_a?(Hash)
79
+ limit = qi[:limit] if qi.is_a?(Hash)
80
+ metric = qi[:metric_name] if qi.is_a?(Hash)
81
+
82
+ region = dimensions[:region] if dimensions.is_a?(Hash)
83
+
84
+ limit_msg = " Limit: #{limit.to_f}" if limit.is_a?(Numeric)
85
+ limit_msg = "#{limit_msg} #{metric}" if limit_msg && metric
86
+ limit_msg = "#{limit_msg} in region #{region}" if limit_msg && region.is_a?(String)
87
+ limit_msg = "#{limit_msg}." if limit_msg
88
+
89
+ msg = "#{msg}#{limit_msg}"
90
+ end
91
+
92
+ msg
93
+ end
94
+ end # QuotaInfo
95
+
96
+
97
+ def error?
98
+ ! error.nil?
99
+ end
100
+
101
+ def errors
102
+ error? ? error[:errors] : nil
103
+ end
104
+
29
105
  def ready?
30
106
  status == DONE_STATE
31
107
  end
@@ -42,6 +118,35 @@ module Fog
42
118
  zone.nil? ? nil : zone.split("/")[-1]
43
119
  end
44
120
 
121
+ def error_info_class(code)
122
+ case code
123
+ when "QUOTA_EXCEEDED" then QuotaInfo
124
+ else
125
+ ErrorInfo
126
+ end
127
+ end
128
+
129
+ # Returns an array of ErrorInfo objects derived from the raw error hash.
130
+ def error_infos
131
+ return [] unless error.is_a?(Hash)
132
+ return [] unless errors.is_a?(Array)
133
+
134
+ errors.map do |err|
135
+ klass = error_info_class(err[:code])
136
+ klass.new(
137
+ code: err[:code],
138
+ message: err[:message],
139
+ location: err[:location],
140
+ error_details: err[:error_details]
141
+ )
142
+ end
143
+ end
144
+
145
+ # Convenience helper: return the first error (most Google APIs provide only one).
146
+ def primary_error
147
+ error_infos.first
148
+ end
149
+
45
150
  def destroy
46
151
  requires :identity
47
152
 
@@ -9,6 +9,7 @@ module Fog
9
9
 
10
10
  def initialize(options = {})
11
11
  shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, GOOGLE_STORAGE_JSON_BASE_URL)
12
+ @options = options.dup
12
13
  @client = MockClient.new('test')
13
14
  @storage_json = MockClient.new('test')
14
15
  @iam_service = MockClient.new('test')
@@ -18,6 +19,14 @@ module Fog
18
19
  "foo"
19
20
  end
20
21
 
22
+ 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
28
+ end
29
+
21
30
  def google_access_id
22
31
  "my-account@project.iam.gserviceaccount"
23
32
  end
@@ -47,7 +47,7 @@ module Fog
47
47
 
48
48
  def public_url
49
49
  requires :key
50
- "#{GOOGLE_STORAGE_BUCKET_BASE_URL}#{key}"
50
+ "#{service.bucket_base_url}#{key}"
51
51
  end
52
52
 
53
53
  def save
@@ -97,7 +97,7 @@ module Fog
97
97
 
98
98
  def public_url
99
99
  requires :directory, :key
100
- "https://storage.googleapis.com/#{directory.key}/#{key}"
100
+ "#{service.bucket_base_url}#{directory.key}/#{key}"
101
101
  end
102
102
 
103
103
  FILE_INSERTABLE_FIELDS = %i(
@@ -11,15 +11,16 @@ module Fog
11
11
  attr_reader :storage_json
12
12
 
13
13
  def initialize(options = {})
14
- shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, GOOGLE_STORAGE_JSON_BASE_URL)
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)
15
16
  @options = options.dup
16
17
  options[:google_api_scope_url] = GOOGLE_STORAGE_JSON_API_SCOPE_URLS.join(" ")
17
- @host = options[:host] || "storage.googleapis.com"
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
24
  apply_client_options(@storage_json, options)
24
25
 
25
26
  @storage_json.client_options.open_timeout_sec = options[:open_timeout_sec] if options[:open_timeout_sec]
@@ -27,6 +28,14 @@ module Fog
27
28
  @storage_json.client_options.send_timeout_sec = options[:send_timeout_sec] if options[:send_timeout_sec]
28
29
  end
29
30
 
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
37
+ end
38
+
30
39
  def signature(params)
31
40
  string_to_sign = <<-DATA
32
41
  #{params[:method]}
@@ -17,6 +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
21
  :open_timeout_sec,
21
22
  :read_timeout_sec,
22
23
  :send_timeout_sec
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Google
3
- VERSION = "1.26.0".freeze
3
+ VERSION = "1.28.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.26.0
4
+ version: 1.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Welch
@@ -196,14 +196,14 @@ dependencies:
196
196
  requirements:
197
197
  - - '='
198
198
  - !ruby/object:Gem::Version
199
- version: 0.15.2
199
+ version: 0.16.0
200
200
  type: :development
201
201
  prerelease: false
202
202
  version_requirements: !ruby/object:Gem::Requirement
203
203
  requirements:
204
204
  - - '='
205
205
  - !ruby/object:Gem::Version
206
- version: 0.15.2
206
+ version: 0.16.0
207
207
  - !ruby/object:Gem::Dependency
208
208
  name: retriable
209
209
  requirement: !ruby/object:Gem::Requirement
@@ -246,6 +246,20 @@ dependencies:
246
246
  - - ">="
247
247
  - !ruby/object:Gem::Version
248
248
  version: '0'
249
+ - !ruby/object:Gem::Dependency
250
+ name: minitest-mock
251
+ requirement: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ version: '0'
256
+ type: :development
257
+ prerelease: false
258
+ version_requirements: !ruby/object:Gem::Requirement
259
+ requirements:
260
+ - - ">="
261
+ - !ruby/object:Gem::Version
262
+ version: '0'
249
263
  - !ruby/object:Gem::Dependency
250
264
  name: minitest-reporters
251
265
  requirement: !ruby/object:Gem::Requirement