miasma-aws 0.1.4 → 0.1.6

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
  SHA1:
3
- metadata.gz: a36b7462b9d20c66ddf295b05ebdf6e040347506
4
- data.tar.gz: 0f5d54d5fe39d9875113c9780129bf00b5ecfa10
3
+ metadata.gz: a3da765abdba597864cae9b1fe0b1c81900c2a94
4
+ data.tar.gz: b98aab91fd9511e26ca5dbc42a8a6b8dc1730f41
5
5
  SHA512:
6
- metadata.gz: 8e3d201264bee490fb391aa998fc57590d270543f4d82556444fcc875f2838b61eb2187a2f29e859a0a8279865bf278c99be651a93f554428a3692c808bc6683
7
- data.tar.gz: 9ff5d373105120f4ecc53a94cb0cb3847c1d426b5bf845edd1774b91cad1d917a51d045a0fe4a327400e083c71512c5d57c1dae6d9e363123dd8718aeb1a32e4
6
+ metadata.gz: e1ae3d106af0bcc11a2893a8efab2eabe9980090203409ccfb8127e09afb63df62887ea71a0ae55f7656a06903e59ac3b736bd9d101075f4f6613442a3316228
7
+ data.tar.gz: 5f49561b607f000311ec3f530426f2898ca1e9278d0bcb5e472811539df9aeef34e32fc7ff378d2d49ed7fe25bd80fa5813410680fcf400d1b08f7c9802c547e
@@ -1,3 +1,7 @@
1
+ ## v0.1.6
2
+ * Fix state assignment when undefined within orchestration stacks
3
+ * Fix multi-part S3 uploads
4
+
1
5
  ## v0.1.4
2
6
  * Fix values set within load balancer reload
3
7
  * Ensure state is valid for orchestration stack prior to set
@@ -1,4 +1,4 @@
1
1
  module MiasmaAws
2
2
  # Current library version
3
- VERSION = Gem::Version.new('0.1.4')
3
+ VERSION = Gem::Version.new('0.1.6')
4
4
  end
@@ -394,18 +394,21 @@ module Miasma
394
394
  # @param http_method [Symbol]
395
395
  # @param request_args [Array]
396
396
  # @return [HTTP::Response]
397
- # @note if http_method is :post, params will be automatically
398
- # removed and placed into :form
399
397
  def make_request(connection, http_method, request_args)
400
398
  dest, options = request_args
401
399
  path = URI.parse(dest).path
402
400
  options = options ? options.to_smash : Smash.new
403
- options[:params] = options.fetch(:params, Smash.new).to_smash.deep_merge('Version' => self.class::API_VERSION)
404
- if(http_method.to_sym == :post)
401
+ if(self.class::API_VERSION)
405
402
  if(options[:form])
406
- options[:form].merge(options.delete(:params))
403
+ options.set(:form, 'Version', self.class::API_VERSION)
407
404
  else
408
- options[:form] = options.delete(:params)
405
+ options[:params] = options.fetch(
406
+ :params, Smash.new
407
+ ).to_smash.deep_merge(
408
+ Smash.new(
409
+ 'Version' => self.class::API_VERSION
410
+ )
411
+ )
409
412
  end
410
413
  end
411
414
  update_request(connection, options)
@@ -75,8 +75,8 @@ module Miasma
75
75
  state = stk['StackStatus'].downcase.to_sym
76
76
  unless(Miasma::Models::Orchestration::VALID_RESOURCE_STATES.include?(state))
77
77
  parts = state.to_s.split('_')
78
- state = [state.first, *state.slice(-2, state.size)].join('_').to_sym
79
- unless(Miasma::Models::Orchestration::VALID_RESOURCE_STATES.include?(state))
78
+ state = [parts.first, *parts.slice(-2, parts.size)].join('_').to_sym
79
+ unless(Miasma::Models::Orchestration::VALID_RESOURCE_STATES.include?(parts))
80
80
  state = :unknown
81
81
  end
82
82
  end
@@ -136,7 +136,7 @@ module Miasma
136
136
  result = request(
137
137
  :path => '/',
138
138
  :method => :post,
139
- :params => Smash.new(
139
+ :form => Smash.new(
140
140
  'Action' => 'UpdateStack'
141
141
  ).merge(params)
142
142
  )
@@ -148,7 +148,7 @@ module Miasma
148
148
  result = request(
149
149
  :path => '/',
150
150
  :method => :post,
151
- :params => Smash.new(
151
+ :form => Smash.new(
152
152
  'Action' => 'CreateStack',
153
153
  'DisableRollback' => !!stack.disable_rollback
154
154
  ).merge(params)
@@ -227,7 +227,7 @@ module Miasma
227
227
  result = request(
228
228
  :method => :post,
229
229
  :path => '/',
230
- :params => Smash.new(
230
+ :form => Smash.new(
231
231
  'Action' => 'ValidateTemplate',
232
232
  'TemplateBody' => MultiJson.dump(stack.template)
233
233
  )
@@ -9,7 +9,7 @@ module Miasma
9
9
 
10
10
  # Service name of the API
11
11
  API_SERVICE = 's3'
12
- # Supported version of the AutoScaling API
12
+ # Supported version of the Storage API
13
13
  API_VERSION = '2006-03-01'
14
14
 
15
15
  include Contrib::AwsApiCore::ApiCommon
@@ -191,7 +191,7 @@ module Miasma
191
191
  if(file.dirty?)
192
192
  file.load_data(file.attributes)
193
193
  args = Smash.new
194
- args[:headers] = Smash[
194
+ headers = Smash[
195
195
  Smash.new(
196
196
  :content_type => 'Content-Type',
197
197
  :content_disposition => 'Content-Disposition',
@@ -202,73 +202,90 @@ module Miasma
202
202
  end
203
203
  end.compact
204
204
  ]
205
- if(file.attributes[:body].is_a?(IO) && file.body.size >= Storage::MAX_BODY_SIZE_FOR_STRINGIFY)
205
+ unless(headers.empty?)
206
+ args[:headers] = headers
207
+ end
208
+ if(file.attributes[:body].respond_to?(:read) && file.attributes[:body].size >= Storage::MAX_BODY_SIZE_FOR_STRINGIFY)
206
209
  upload_id = request(
207
210
  args.merge(
208
211
  Smash.new(
212
+ :method => :post,
209
213
  :path => file_path(file),
210
- :endpoint => bucket_endpoint(bucket),
214
+ :endpoint => bucket_endpoint(file.bucket),
211
215
  :params => {
212
216
  :uploads => true
213
217
  }
214
218
  )
215
219
  )
216
220
  ).get(:body, 'InitiateMultipartUploadResult', 'UploadId')
217
- count = 1
218
- parts = []
219
- file.body.rewind
220
- while(content = file.body.read(Storage::READ_BODY_CHUNK_SIZE))
221
- parts << [
222
- count,
223
- request(
224
- :method => :put,
225
- :path => file_path(file),
226
- :endpoint => bucket_endpoint(bucket),
227
- :headers => Smash.new(
228
- 'Content-Length' => content.size,
229
- 'Content-MD5' => Digest::MD5.hexdigest(content)
230
- ),
231
- :params => Smash.new(
232
- 'partNumber' => count,
233
- 'uploadId' => upload_id
234
- ),
235
- :body => content
236
- ).get(:body, :headers, :etag)
237
- ]
238
- count += 1
239
- end
240
- complete = SimpleXml.xml_out(
241
- Smash.new(
242
- 'CompleteMultipartUpload' => {
243
- 'Part' => parts.map{|part|
244
- {'PartNumber' => part.first, 'ETag' => part.last}
221
+ begin
222
+ count = 1
223
+ parts = []
224
+ file.body.rewind
225
+ while(content = file.body.read(Storage::READ_BODY_CHUNK_SIZE))
226
+ parts << [
227
+ count,
228
+ request(
229
+ :method => :put,
230
+ :path => file_path(file),
231
+ :endpoint => bucket_endpoint(file.bucket),
232
+ :headers => Smash.new(
233
+ 'Content-Length' => content.size,
234
+ 'Content-MD5' => Base64.urlsafe_encode64(Digest::MD5.digest(content))
235
+ ),
236
+ :params => Smash.new(
237
+ 'partNumber' => count,
238
+ 'uploadId' => upload_id
239
+ ),
240
+ :body => content
241
+ ).get(:headers, :etag)
242
+ ]
243
+ count += 1
244
+ end
245
+ complete = XmlSimple.xml_out(
246
+ Smash.new(
247
+ 'CompleteMultipartUpload' => {
248
+ 'Part' => parts.map{|part|
249
+ {'PartNumber' => part.first, 'ETag' => part.last}
250
+ }
245
251
  }
246
- }
247
- ),
248
- 'AttrPrefix' => true,
249
- 'KeepRoot' => true
250
- )
251
- result = request(
252
- :method => :post,
253
- :path => file_path(file),
254
- :endpoint => bucket_endpoint(file.bucket),
255
- :params => Smash.new(
256
- 'UploadId' => upload_id
257
- ),
258
- :headers => Smash.new(
259
- 'Content-Length' => complete.size
260
- ),
261
- :body => complete
262
- )
263
- file.etag = result.get(:body, 'CompleteMultipartUploadResult', 'ETag')
252
+ ),
253
+ 'AttrPrefix' => true,
254
+ 'KeepRoot' => true
255
+ )
256
+ result = request(
257
+ :method => :post,
258
+ :path => file_path(file),
259
+ :endpoint => bucket_endpoint(file.bucket),
260
+ :params => Smash.new(
261
+ 'uploadId' => upload_id
262
+ ),
263
+ :headers => Smash.new(
264
+ 'Content-Length' => complete.size
265
+ ),
266
+ :body => complete
267
+ )
268
+ file.etag = result.get(:body, 'CompleteMultipartUploadResult', 'ETag')
269
+ rescue
270
+ request(
271
+ :method => :delete,
272
+ :path => file_path(file),
273
+ :endpoint => bucket_endpoint(file.bucket),
274
+ :params => {
275
+ 'uploadId' => upload_id
276
+ },
277
+ :expects => 204
278
+ )
279
+ raise
280
+ end
264
281
  else
265
282
  if(file.attributes[:body].respond_to?(:readpartial))
266
- args[:headers]['Content-Length'] = file.body.size.to_s
283
+ args.set(:headers, 'Content-Length', file.body.size.to_s)
267
284
  file.body.rewind
268
285
  args[:body] = file.body.readpartial(file.body.size)
269
286
  file.body.rewind
270
287
  else
271
- args[:headers]['Content-Length'] = 0
288
+ args.set(:headers, 'Content-Length', 0)
272
289
  end
273
290
  result = request(
274
291
  args.merge(
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = 'Smoggy AWS API'
11
11
  s.license = 'Apache 2.0'
12
12
  s.require_path = 'lib'
13
- s.add_development_dependency 'miasma', '>= 0.2.16'
13
+ s.add_development_dependency 'miasma', '>= 0.2.18'
14
14
  s.add_development_dependency 'pry'
15
15
  s.add_development_dependency 'minitest'
16
16
  s.add_development_dependency 'vcr'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miasma-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: miasma
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.16
19
+ version: 0.2.18
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.16
26
+ version: 0.2.18
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement