fog-google 1.26.0 → 1.27.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: 324898488d484b7d2bf5e875ebe152c545607044090f4786941f8106754b4433
4
+ data.tar.gz: ae49e89d5e42127efde49e52340e751e1c075f100fe19b03e5bc3c88399a2e99
5
5
  SHA512:
6
- metadata.gz: 7fed398133b6232a92ada212c143d65228dbb3a0d6c49b1842256ef79b1fea2a2bf9add46947459d2afb4b3df4f69fb74b49bfe14f0a6459cceab7adb4518ae1
7
- data.tar.gz: 53397624bfcdb357853bba55725c9c60336c734fe0ecb81f812cabed0945cb9009b93b2d3b6ff04e3673082ebee82d1fdda647f55631dced3f27673a8f6f1430
6
+ metadata.gz: 56f151cbc7b3b170b90537b26410517f29c769ca6168fbc16bdd9937e89bfc44c315da223cf7dfae916775626c985b67db07c9e15aacfcb8e6a69d8f082a23b3
7
+ data.tar.gz: 3a44a91f409c99d4caa368bc6d8f30e131f6cb566e66926b9bec27a9a25aa4b453b2bb27a5526f1420553a06caa569520712962fd8011d842f82bc2ab1926201
@@ -42,7 +42,7 @@ jobs:
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:
@@ -42,7 +42,7 @@ jobs:
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:
@@ -42,7 +42,7 @@ jobs:
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:
@@ -41,7 +41,7 @@ jobs:
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:
@@ -42,7 +42,7 @@ jobs:
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:
@@ -42,7 +42,7 @@ jobs:
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:
@@ -42,7 +42,7 @@ jobs:
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:
@@ -43,7 +43,7 @@ jobs:
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:
@@ -19,7 +19,7 @@ jobs:
19
19
  ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4', '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,19 @@ 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
+ ### Fixed
12
+
13
+ - #648 raise exception if disk quota exceeded [rchekaluk]
14
+
15
+ ### Development changes
16
+
17
+ - #647 bump actions/checkout from 5 to 6 [dependabot]
18
+ - #649 bump pry from = 0.15.2 to = 0.16.0 [dependabot]
19
+
7
20
  ## 1.26.0
8
21
 
9
22
  ### User-facing
data/fog-google.gemspec CHANGED
@@ -38,7 +38,7 @@ 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"
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Google
3
- VERSION = "1.26.0".freeze
3
+ VERSION = "1.27.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.27.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