miasma-aws 0.1.10 → 0.1.12

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: 0be997cc62659a51d4ae788959b0e583eda2057b
4
- data.tar.gz: 0ede4c40792335c6b4deab9b55566f943916d212
3
+ metadata.gz: 2967860cfc9a00bdddaeec82c625e67b0deebbc2
4
+ data.tar.gz: 5aed93a44a616148a18a432b2e5f6a94b41c2958
5
5
  SHA512:
6
- metadata.gz: 599452ef733b413350ed1a723cdce5289e8bae389e7528d250d0404627054621bb86955085e43d15e47ce2a9c7ae625f7639e7adb21db35ab29edb23505853f2
7
- data.tar.gz: 486b6b394e09d03aaf8247ee52ee14e01e02d0dad6a6606631da754507c4acc2a862a84d61e3a58c23c2a3cc135e33784b3eaf04b27ce8460a79ef7ac1e35090
6
+ metadata.gz: 83cc2ff04ee739492a8c721d532c1c801f4e2a409c1472c5221c8e5cb67524406b067fa832d1307113e6621ae38eb83e08808cbaca507c0e798463a644f81e1e
7
+ data.tar.gz: 8ed083d3348fd7dfc087c7195275b5c272bb8500e05c1a45eda9fef0978862cd3aee6ad55105916a4f43dd9aab3318e96f1cd99149713e0152bd5eb71e3fb984
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v0.1.12
2
+ * Update default file paths to use `Dir.home` instead of ~ expansion
3
+ * Fix bug reading .aws/credentials when whitespace is used
4
+ * Add support for .aws/config
5
+ * Auto detect us-east-1 region and do not use custom s3 endpoint
6
+
1
7
  ## v0.1.10
2
8
  * Fix disable rollback mapping value to on failure
3
9
 
@@ -1,4 +1,4 @@
1
1
  module MiasmaAws
2
2
  # Current library version
3
- VERSION = Gem::Version.new('0.1.10')
3
+ VERSION = Gem::Version.new('0.1.12')
4
4
  end
@@ -327,8 +327,9 @@ module Miasma
327
327
 
328
328
  def self.included(klass)
329
329
  klass.class_eval do
330
- attribute :aws_profile_name, String
331
- attribute :aws_credentials_file, String, :required => true, :default => File.expand_path('~/.aws/credentials')
330
+ attribute :aws_profile_name, String, :default => 'default'
331
+ attribute :aws_credentials_file, String, :required => true, :default => File.join(Dir.home, '.aws/credentials')
332
+ attribute :aws_config_file, String, :required => true, :default => File.join(Dir.home, '.aws/config')
332
333
  attribute :aws_access_key_id, String, :required => true
333
334
  attribute :aws_secret_access_key, String, :required => true
334
335
  attribute :aws_region, String, :required => true
@@ -364,34 +365,49 @@ module Miasma
364
365
  # @return [TrueClass]
365
366
  def custom_setup(creds)
366
367
  if(creds[:aws_profile_name])
367
- creds.replace(load_aws_credentials(creds[:aws_profile_name]).merge(creds))
368
+ creds.replace(
369
+ load_aws_file(
370
+ aws_config_file,
371
+ creds[:aws_profile_name]
372
+ ).merge(
373
+ load_aws_file(
374
+ aws_credentials_file,
375
+ creds[:aws_profile_name]
376
+ )
377
+ ).merge(creds)
378
+ )
368
379
  end
369
380
  end
370
381
 
371
- # Load credentials from the AWS credentials file
382
+ # Load configuration from the AWS configuration file
372
383
  #
384
+ # @param file_path [String] path to configuration file
373
385
  # @param profile [String] name of profile to load
374
386
  # @return [Smash]
375
- def load_aws_credentials(profile)
376
- credentials = Smash.new.tap do |creds|
377
- key = nil
378
- File.readlines(aws_credentials_file).each do |line|
379
- line.strip!
380
- if(line.start_with?('[') && line.end_with?(']'))
381
- key = line.tr('[]', '')
382
- creds[key] = Smash.new
383
- else
384
- creds[key].merge!(Smash[*line.split('=')])
387
+ def load_aws_file(file_path, profile)
388
+ if(File.exists?(file_path))
389
+ l_config = Smash.new.tap do |creds|
390
+ key = nil
391
+ File.readlines(file_path).each do |line|
392
+ line.strip!
393
+ if(line.start_with?('[') && line.end_with?(']'))
394
+ key = line.tr('[]', '').strip
395
+ creds[key] = Smash.new
396
+ else
397
+ creds[key].merge!(Smash[*line.split('=').map(&:strip)])
398
+ end
385
399
  end
386
400
  end
387
- end
388
- credentials.fetch(
389
- :default, Smash.new
390
- ).merge(
391
- credentials.fetch(
392
- profile, Smash.new
401
+ l_config.fetch(
402
+ :default, Smash.new
403
+ ).merge(
404
+ l_config.fetch(
405
+ profile, Smash.new
406
+ )
393
407
  )
394
- )
408
+ else
409
+ Smash.new
410
+ end
395
411
  end
396
412
 
397
413
  # Setup for API connections
@@ -23,7 +23,7 @@ module Miasma
23
23
  args[:aws_region] = args.fetch(:aws_bucket_region, 'us-east-1')
24
24
  super(args)
25
25
  aws_region = cache_region
26
- if(aws_bucket_region)
26
+ if(aws_bucket_region && aws_bucket_region != 'us-east-1')
27
27
  self.aws_host = "s3-#{aws_bucket_region}.amazonaws.com"
28
28
  else
29
29
  self.aws_host = 's3.amazonaws.com'
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.10
4
+ version: 0.1.12
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-04-15 00:00:00.000000000 Z
11
+ date: 2015-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: miasma
@@ -137,4 +137,3 @@ signing_key:
137
137
  specification_version: 4
138
138
  summary: Smoggy AWS API
139
139
  test_files: []
140
- has_rdoc: