opzworks 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 717f106caa4c53964b54329433f943fb01a2f489
4
- data.tar.gz: 8ff92afd826f24410fb197b69325fb6b038c4d3d
3
+ metadata.gz: f740b238f93e2c1ddfec5ef71c0686656569b4d6
4
+ data.tar.gz: dc99860d8e4cd003523845d78a7c3552c6c6fd84
5
5
  SHA512:
6
- metadata.gz: 7957769cf6b467357c0f0e6a9f64491ae88110eb84fa57f20e3693c8e412ca0214a483ea1b42bc3c55f051e59362eb41362a2fe1858f91c2f3e35ad23548e6d6
7
- data.tar.gz: 3d5757e3ccbfc99b45b024673c7c809c29d36c4bdec5ae27cbc66c375b40041d27ac9738cc67b58c5feaaa68ebbfbc9866f1f5c9de761713ae6cfefb95469697
6
+ metadata.gz: 1a2f20a5c0938a6c0289cdd919fba88e040f4bcc9a9c81faa79911ca8e5b2f0029ce0a86bec0255f6c7f8813b2a83b1c77d4c14eb2ba4f6d3ddb93bc7cdbe0dc
7
+ data.tar.gz: 8f6bd7aef86c74bb4d03367dee0ccf61db4b1cbc230ee310cf9d9faffd1843e2932488e271487be54dff8fe4443589f4d7f2962ff99b4d8cc797cd7511c41071
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  changelog
2
2
  =========
3
3
 
4
+ 0.12.0
5
+ ------
6
+ * update aws-sdk dependency to 2.2.37
7
+ * create backups of cookbook tarball before uploading new
8
+
4
9
  0.11.1
5
10
  ------
6
11
  * bump aws-sdk dependency
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opzworks (0.11.0)
5
- aws-sdk (~> 2.2.26)
4
+ opzworks (0.11.1)
5
+ aws-sdk (~> 2.2.37)
6
6
  diffy (~> 3.1.0)
7
7
  faraday (~> 0.9.2)
8
8
  inifile (~> 3.0.0)
@@ -16,12 +16,12 @@ GEM
16
16
  specs:
17
17
  ast (2.2.0)
18
18
  awesome_print (1.6.1)
19
- aws-sdk (2.2.26)
20
- aws-sdk-resources (= 2.2.26)
21
- aws-sdk-core (2.2.26)
19
+ aws-sdk (2.2.37)
20
+ aws-sdk-resources (= 2.2.37)
21
+ aws-sdk-core (2.2.37)
22
22
  jmespath (~> 1.0)
23
- aws-sdk-resources (2.2.26)
24
- aws-sdk-core (= 2.2.26)
23
+ aws-sdk-resources (2.2.37)
24
+ aws-sdk-core (= 2.2.37)
25
25
  diffy (3.1.0)
26
26
  faraday (0.9.2)
27
27
  multipart-post (>= 1.2, < 3)
@@ -37,6 +37,7 @@ module OpzWorks
37
37
 
38
38
  aws_credentials_provider = Aws::SharedCredentials.new(profile_name: config.aws_profile)
39
39
  s3 = Aws::S3::Resource.new(region: config.aws_region, credentials: aws_credentials_provider)
40
+ s3_client = Aws::S3::Client.new(region: config.aws_region, credentials: aws_credentials_provider)
40
41
 
41
42
  opsworks = Aws::OpsWorks::Client.new(region: config.aws_region, profile: config.aws_profile)
42
43
  response = opsworks.describe_stacks
@@ -64,6 +65,7 @@ module OpzWorks
64
65
  next if var == false
65
66
  next if options[:clone] == true
66
67
 
68
+ time = Time.new.utc.strftime("%FT%TZ")
67
69
  berks_cook_path = config.berks_base_path || '/tmp'
68
70
  cook_path = "#{berks_cook_path}/#{@project}-#{@branch}"
69
71
  cookbook_tarball = config.berks_tarball_name || 'cookbooks.tgz'
@@ -110,14 +112,37 @@ module OpzWorks
110
112
  puts "\nCommitting changes and pushing".foreground(:blue)
111
113
  system "cd #{@target_path} && git commit -am 'berks update'; git push origin #{@branch}"
112
114
 
113
- # upload
115
+ # backup previous if it exists
114
116
  #
115
- puts "\nUploading to S3".foreground(:blue)
117
+ begin
118
+ s3_client.head_object(
119
+ bucket: s3_bucket,
120
+ key: "#{@s3_path}/#{cookbook_tarball}"
121
+ )
122
+ rescue Aws::S3::Errors::ServiceError => e
123
+ puts "No existing #{cookbook_tarball} in #{s3_bucket} to backup, continuing...".foreground(:yellow)
124
+ else
125
+ puts "Backing up #{cookbook_tarball} to #{@s3_path}/#{cookbook_tarball}-#{time}".foreground(:green)
126
+ begin
127
+ s3_client.copy_object(
128
+ key: "#{@s3_path}/#{cookbook_tarball}-#{time}",
129
+ bucket: s3_bucket,
130
+ copy_source: "#{s3_bucket}/#{@s3_path}/#{cookbook_tarball}"
131
+ )
132
+ rescue Aws::S3::Errors::ServiceError => e
133
+ puts "Caught exception trying to backup existing #{cookbook_tarball} in #{s3_bucket}:".foreground(:red)
134
+ puts "\t#{e}"
135
+ abort
136
+ end
137
+ end
116
138
 
139
+ # upload
117
140
  begin
141
+ puts "\nUploading to S3".foreground(:blue)
142
+
118
143
  obj = s3.bucket(s3_bucket).object("#{@s3_path}/#{cookbook_tarball}")
119
144
  obj.upload_file(cookbook_upload)
120
- rescue StandardError => e
145
+ rescue Aws::S3::Errors::ServiceError => e
121
146
  puts "Caught exception while uploading to S3 bucket #{s3_bucket}:".foreground(:red)
122
147
  puts "\t#{e}"
123
148
  puts "\nCleaning up before exiting".foreground(:blue)
data/lib/opzworks/meta.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module OpzWorks
3
- VERSION = '0.11.1'.freeze
3
+ VERSION = '0.12.0'.freeze
4
4
  AUTHORS = ['Grant Heffernan', 'Mapzen'].freeze
5
5
  EMAIL = ['grant@mapzen.com'].freeze
6
6
  DESCRIPTION = 'OpzWorks Utilities'.freeze
data/opzworks.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_dependency 'aws-sdk', '~> 2.2.26'
28
+ spec.add_dependency 'aws-sdk', '~> 2.2.37'
29
29
  spec.add_dependency 'trollop', '~> 2.0'
30
30
  spec.add_dependency 'inifile', '~> 3.0.0'
31
31
  spec.add_dependency 'diffy', '~> 3.1.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opzworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Heffernan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-14 00:00:00.000000000 Z
12
+ date: 2016-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 2.2.26
20
+ version: 2.2.37
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 2.2.26
27
+ version: 2.2.37
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: trollop
30
30
  requirement: !ruby/object:Gem::Requirement