simple_deploy 0.7.6.beta.1 → 0.7.6.beta.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 05edf27f77f29c8d99c992b7736ba3393543e8a2
4
+ data.tar.gz: 51710aa5eac62c1943b959f4929962d53150c027
5
+ SHA512:
6
+ metadata.gz: 38ecf0947147ad91ef5ba62d1ed7c8c077b14a10395e82f902e5817b07b5cf8eeb1bea171a90b71268a45059f98445b3216758faf12a93810796640c70b4a448
7
+ data.tar.gz: 21e5b0507a33b06b84d3a8ea21d50402c28d6f6c5ca8f062bd206b0c4a22b27e62c58433da27e579a1a0e5e0bbd29dd5d9e5009d2917787c5c184f6bc81cbd32
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  coverage
6
- .ruby-version
7
- .rvmrc
8
6
  *.swp
9
7
  .idea/*
8
+ .DS_Store
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ simple_deploy
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p247
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ## HEAD:
2
2
 
3
+ * Added feature for issue 169 to remove values which are set to nil
4
+ * Added feature for issue 191 to read in input stack for clone command
3
5
  * Fixed issue 176 where multiple deploys did not exit if first deploy failed
4
6
  * Fixed find_xml_file error when a blank exception is thrown from cloudformation.
5
7
 
@@ -20,7 +20,8 @@ module SimpleDeploy
20
20
  when 'No updates are to be performed.'
21
21
  @logger.info msg
22
22
  when /Template requires parameter(.*)/
23
- @logger.info msg
23
+ @logger.error msg
24
+ raise Exceptions::CloudFormationError.new msg
24
25
  when /^Stack:(.*) does not exist$/
25
26
  @logger.error msg
26
27
  raise Exceptions::UnknownStack.new msg
@@ -47,6 +47,10 @@ module SimpleDeploy
47
47
  @connect.delete_attributes domain, key
48
48
  end
49
49
 
50
+ def delete_items(domain, key, attributes)
51
+ @connect.delete_attributes domain, key, attributes
52
+ end
53
+
50
54
  end
51
55
  end
52
56
  end
@@ -19,6 +19,10 @@ simple_deploy clone -s SOURCE_STACK_NAME -n NEW_STACK_NAME -e ENVIRONMENT -a ATT
19
19
  EOS
20
20
  opt :help, "Display Help"
21
21
  opt :environment, "Set the target environment", :type => :string
22
+ opt :input_stack, "Read outputs from given stack(s) and map them \
23
+ to parameter inputs in the new stack. These will be passed to inputs with \
24
+ matching or pluralized names. Can be specified multiple times.", :type => :string,
25
+ :multi => true
22
26
  opt :log_level, "Log level: debug, info, warn, error", :type => :string,
23
27
  :default => 'info'
24
28
  opt :source_name, "Stack name for the stack to clone", :type => :string
@@ -35,10 +39,7 @@ EOS
35
39
  SimpleDeploy.logger @opts[:log_level]
36
40
 
37
41
  override_attributes = parse_attributes :attributes => @opts[:attributes]
38
-
39
42
  cloned_attributes = filter_attributes source_stack.attributes
40
- new_attributes = merge_attributes cloned_attributes, override_attributes
41
- new_attributes += add_attributes cloned_attributes, override_attributes
42
43
 
43
44
  template_file = Tempfile.new("#{@opts[:new_name]}_template.json")
44
45
  template_file_path = template_file.path
@@ -49,6 +50,18 @@ EOS
49
50
  template_file.write source_stack.template
50
51
  end
51
52
 
53
+ if @opts[:input_stack]
54
+ input_attributes = mapper.map_outputs_from_stacks :stacks => @opts[:input_stack],
55
+ :template => template_file_path
56
+ new_overrides = merge_attributes input_attributes, override_attributes
57
+ new_overrides += add_attributes input_attributes, override_attributes
58
+ else
59
+ new_overrides = override_attributes
60
+ end
61
+
62
+ new_attributes = merge_attributes cloned_attributes, new_overrides
63
+ new_attributes += add_attributes cloned_attributes, new_overrides
64
+
52
65
  rescue_exceptions_and_exit do
53
66
  new_stack.create :attributes => new_attributes,
54
67
  :template => template_file_path
@@ -83,6 +96,10 @@ EOS
83
96
  end.compact
84
97
  end
85
98
 
99
+ def mapper
100
+ @om ||= Stack::OutputMapper.new :environment => @opts[:environment]
101
+ end
102
+
86
103
  def source_stack
87
104
  @source_stack = Stack.new :name => @opts[:source_name],
88
105
  :environment => @opts[:environment]
@@ -86,11 +86,11 @@ EOS
86
86
  if result
87
87
  notifier.send_deployment_complete_message unless @opts[:quiet]
88
88
  else
89
- logger.error "Deployment to #{name} did not complete succesfully."
89
+ logger.error "Deployment to #{name} did not complete successfully."
90
90
  exit 1
91
91
  end
92
92
  else
93
- logger.error "Update of #{name} did not complete succesfully."
93
+ logger.error "Update of #{name} did not complete successfully."
94
94
  exit 1
95
95
  end
96
96
 
@@ -28,26 +28,33 @@ module SimpleDeploy
28
28
  end
29
29
 
30
30
  def set_attributes(a)
31
- a.each { |attribute| @custom_attributes.merge! attribute }
31
+ a.each do |attribute|
32
+ @custom_attributes.merge! attribute
33
+ end
32
34
  end
33
35
 
34
36
  def save
35
- @custom_attributes.merge! 'Name' => name,
37
+ @custom_attributes.merge! 'Name' => name,
36
38
  'CreatedAt' => Time.now.utc.to_s
37
39
 
38
- current_attributes = attributes
39
- current_attributes.each_pair do |key,value|
40
- @logger.debug "Setting attribute #{key}=#{value}"
40
+ current_attributes = attributes.reject do |key,value|
41
+ if value == 'nil'
42
+ @logger.info "Removing attribute set to nil '#{key}'."
43
+ sdb_connect.delete_items 'stacks', name, key => nil
44
+ true
45
+ end
41
46
  end
42
47
 
43
- sdb_connect.put_attributes('stacks',
44
- name,
45
- current_attributes,
46
- :replace => current_attributes.keys )
48
+ current_attributes.each_pair {|k,v| @logger.debug "Setting attribute #{k}=#{v}"}
47
49
 
48
- @logger.debug "Save to SimpleDB successful."
49
- end
50
+ sdb_connect.put_attributes 'stacks',
51
+ name,
52
+ current_attributes,
53
+ :replace => current_attributes.keys
50
54
 
55
+ @logger.debug "Save to SimpleDB successful."
56
+ end
57
+
51
58
  def delete_attributes
52
59
  sdb_connect.delete('stacks', name)
53
60
  @logger.info "Delete from SimpleDB successful."
@@ -15,7 +15,6 @@ module SimpleDeploy
15
15
  merge_stacks_outputs
16
16
 
17
17
  pluralize_keys
18
-
19
18
  prune_unused_parameters
20
19
 
21
20
  @results.each_pair do |key, value|
@@ -51,6 +51,10 @@ module SimpleDeploy
51
51
  h = {}
52
52
  entry_attributes = @entry.attributes
53
53
  template_parameters.each do |p|
54
+ if entry_attributes[p] == 'nil'
55
+ @logger.debug "Skipping attribute #{p}"
56
+ next
57
+ end
54
58
  h[p] = entry_attributes[p] if entry_attributes[p]
55
59
  end
56
60
  h
@@ -1,3 +1,3 @@
1
1
  module SimpleDeploy
2
- VERSION = "0.7.6.beta.1"
2
+ VERSION = "0.7.6.beta.3"
3
3
  end
@@ -85,5 +85,13 @@ describe SimpleDeploy::AWS::SimpleDB do
85
85
 
86
86
  @db.delete('domain1', 'item1').body['RequestId'].should == 'rid'
87
87
  end
88
+ end
89
+
90
+ describe 'delete_items' do
91
+ it 'should delete the specific attributes passed associated with domain and key' do
92
+ @db_mock.should_receive(:delete_attributes).with('domain1', 'item1', {'value'=>nil}).and_return(@response_stub)
93
+
94
+ @db.delete_items('domain1', 'item1', {'value'=>nil}).body['RequestId'].should == 'rid'
95
+ end
88
96
  end
89
97
  end
@@ -186,6 +186,46 @@ describe SimpleDeploy::CLI::Clone do
186
186
 
187
187
  subject.clone
188
188
  end
189
+
190
+ it 'should create the new stack using existing input stack, but cmd line args win' do
191
+ options = { :environment => 'my_env',
192
+ :input_stack => 'input_stack',
193
+ :template => 'brand_new_template.json',
194
+ :log_level => 'debug',
195
+ :source_name => 'source_stack',
196
+ :new_name => 'new_stack',
197
+ :attributes => ['chef_repo_bucket_prefix=updated-intu-lc',
198
+ 'chef_repo_domain=updated_community_chef_repo',
199
+ 'SolrClientTrafficContainer=solr-client-traffic-container',
200
+ 'InputStackOutputs=cmdline_value'] }
201
+
202
+ input_attributes = [{'InputStackOutputs' => 'inputvalue'}, {'OutputValue' => 'outputs'}]
203
+ input_stub = stub 'input', :map_outputs_from_stacks => input_attributes
204
+ SimpleDeploy::Stack::OutputMapper.stub :new => input_stub
205
+
206
+ subject.should_receive(:valid_options?).
207
+ with(:provided => options,
208
+ :required => [:environment, :source_name, :new_name])
209
+ Trollop.stub(:options).and_return(options)
210
+
211
+ @new_stack_mock.stub(:template).and_return('foo' => 'bah')
212
+ @new_stack_mock.should_receive(:create) do |options|
213
+ options[:attributes].should == [{ 'AmiId' => 'ami-7b6a4e3e' },
214
+ { 'AppEnv' => 'pod-2-cd-1' },
215
+ { 'MaximumAppInstances' => 1 },
216
+ { 'MinimumAppInstances' => 1 },
217
+ { 'chef_repo_bucket_prefix' => 'updated-intu-lc' },
218
+ { 'chef_repo_domain' => 'updated_community_chef_repo' },
219
+ { 'InputStackOutputs' => 'cmdline_value' },
220
+ { 'OutputValue' => 'outputs'},
221
+ { 'SolrClientTrafficContainer' => 'solr-client-traffic-container' }]
222
+
223
+ options[:template].should match /brand_new_template.json/
224
+ end
225
+
226
+ subject.clone
227
+ end
228
+
189
229
  end
190
230
  end
191
231
  end
data/spec/entry_spec.rb CHANGED
@@ -73,6 +73,37 @@ describe SimpleDeploy::Entry do
73
73
  @entry.save
74
74
  end
75
75
 
76
+ it "should remove attributes set to nil" do
77
+ Timecop.travel Time.utc(2012, 10, 22, 13, 30)
78
+
79
+ @simple_db_mock.should_receive(:select).
80
+ with("select * from stacks where itemName() = 'test-stack-us-west-1'").
81
+ and_return('test-stack-us-west-1' => { 'key1' => ['value1'] })
82
+
83
+ @simple_db_mock.should_receive(:delete_items).
84
+ with("stacks",
85
+ "test-stack-us-west-1",
86
+ {'key2' => nil})
87
+
88
+ @simple_db_mock.should_receive(:delete_items).
89
+ with("stacks",
90
+ "test-stack-us-west-1",
91
+ {'key3' => nil})
92
+
93
+
94
+ @simple_db_mock.should_receive(:put_attributes).
95
+ with("stacks",
96
+ "test-stack-us-west-1",
97
+ { "key" => "value",
98
+ "key1" => "value1",
99
+ "Name" => "test-stack-us-west-1",
100
+ "CreatedAt" => "2012-10-22 13:30:00 UTC" },
101
+ { :replace => ["key1", "key", "Name", "CreatedAt"] } )
102
+ @entry.set_attributes(['key' => 'value', 'key2' => 'nil', 'key3' => 'nil'])
103
+
104
+ @entry.save
105
+ end
106
+
76
107
  it "should merge custom attributes" do
77
108
  @simple_db_mock.should_receive(:select).
78
109
  with("select * from stacks where itemName() = 'test-stack-us-west-1'").
@@ -38,7 +38,7 @@ describe SimpleDeploy::StackUpdater do
38
38
  end
39
39
 
40
40
  it "should update the stack when parameters change and stack is stable" do
41
- attributes = { "param1" => "value1", "param3" => "value3" }
41
+ attributes = { "param1" => "value1", "param3" => "value3" , "paramremove" => "nil" }
42
42
  entry_mock = mock 'entry mock'
43
43
  status_mock = mock 'status mock'
44
44
  cloud_formation_mock = mock 'cloud formation mock'
@@ -63,7 +63,7 @@ describe SimpleDeploy::StackUpdater do
63
63
  end
64
64
 
65
65
  it "should update the stack when only the template body changes and stack is stable" do
66
- attributes = { "param1" => "value1", "param3" => "value3" }
66
+ attributes = { "param1" => "value1", "param3" => "value3" , "paramremove" => "nil" }
67
67
  entry_mock = mock 'entry mock'
68
68
  status_mock = mock 'status mock'
69
69
  cloud_formation_mock = mock 'cloud formation mock'
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6.beta.1
5
- prerelease: 6
4
+ version: 0.7.6.beta.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brett Weaver
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-20 00:00:00.000000000 Z
11
+ date: 2013-09-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fakefs
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,23 +27,20 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: simplecov
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: timecop
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: capistrano
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - '='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - '='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: esbit
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: trollop
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - '='
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :runtime
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - '='
140
123
  - !ruby/object:Gem::Version
@@ -142,7 +125,6 @@ dependencies:
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: fog
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - '='
148
130
  - !ruby/object:Gem::Version
@@ -150,7 +132,6 @@ dependencies:
150
132
  type: :runtime
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - '='
156
137
  - !ruby/object:Gem::Version
@@ -158,7 +139,6 @@ dependencies:
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: xml-simple
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
143
  - - '='
164
144
  - !ruby/object:Gem::Version
@@ -166,7 +146,6 @@ dependencies:
166
146
  type: :runtime
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
150
  - - '='
172
151
  - !ruby/object:Gem::Version
@@ -181,6 +160,8 @@ extensions: []
181
160
  extra_rdoc_files: []
182
161
  files:
183
162
  - .gitignore
163
+ - .ruby-gemset
164
+ - .ruby-version
184
165
  - .travis.yml
185
166
  - CHANGELOG.md
186
167
  - Gemfile
@@ -286,27 +267,26 @@ files:
286
267
  - spec/template_spec.rb
287
268
  homepage: ''
288
269
  licenses: []
270
+ metadata: {}
289
271
  post_install_message:
290
272
  rdoc_options: []
291
273
  require_paths:
292
274
  - lib
293
275
  required_ruby_version: !ruby/object:Gem::Requirement
294
- none: false
295
276
  requirements:
296
- - - ! '>='
277
+ - - '>='
297
278
  - !ruby/object:Gem::Version
298
279
  version: '0'
299
280
  required_rubygems_version: !ruby/object:Gem::Requirement
300
- none: false
301
281
  requirements:
302
- - - ! '>'
282
+ - - '>'
303
283
  - !ruby/object:Gem::Version
304
284
  version: 1.3.1
305
285
  requirements: []
306
286
  rubyforge_project: simple_deploy
307
- rubygems_version: 1.8.24
287
+ rubygems_version: 2.0.6
308
288
  signing_key:
309
- specification_version: 3
289
+ specification_version: 4
310
290
  summary: Opinionated gem for AWS resource management.
311
291
  test_files:
312
292
  - spec/artifact_spec.rb