dumbwaiter 0.4.1 → 0.4.2

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: 94944ee58a46b0164e4f7937fcc3b066213f042c
4
- data.tar.gz: 50cdfe19a328a832ff374dc68cbe50900e090b0e
3
+ metadata.gz: a3d7718c5ed04fbb0968d7137db8b407664c2208
4
+ data.tar.gz: 58012f46d1485fc677be218a88accdefe6ea0faa
5
5
  SHA512:
6
- metadata.gz: 0ca9bbc6e30aa1b6dee2a134d419c7180c5586979f83f7c633971de0800eb2f8e2966bb8252f13627b07e082ee5dcef1a95338b9f1359dff34adb90eea7ee9cd
7
- data.tar.gz: fdedb2834345c6a697cf7ff8664473bfd494fc100a396afe13d8e4969c70f294da1269cd7965647da53a998146737e5faa44ff1271534061cba82a39123a2888
6
+ metadata.gz: ca37b421c99a6925f6341f1399e4ec8722d84df5be94bdf7a186da8974beb61bc371bcf3effc5bb22c7ffe6b60d2a5bcfbad8e8695e29caeb96cf10de9af526f
7
+ data.tar.gz: 1dc41bf27d1fbacb8459bc4c3953cc9b4f053c2428dcdcd4fda46cbe2ae2551880e1d9e3432f665b51a23b9fc0af1268aebad69eecc6107ce8a46af89c064a53
@@ -54,6 +54,24 @@ module Dumbwaiter
54
54
  raise Thor::Error.new(e.message)
55
55
  end
56
56
 
57
+ desc "custom_recipes STACK LAYER EVENT", "Show custom recipes for an event"
58
+ def custom_recipes(stack_name, layer_name, event_name)
59
+ stack = Stack.find(stack_name)
60
+ layer = Layer.find(stack, layer_name)
61
+ Kernel.puts(layer.custom_recipes[event_name.to_sym].join(" "))
62
+ rescue Dumbwaiter::Stack::NotFound, Dumbwaiter::Layer::NotFound => e
63
+ raise Thor::Error.new(e.message)
64
+ end
65
+
66
+ desc "update_custom_recipes STACK LAYER EVENT RECIPE...", "Update custom recipes for an event"
67
+ def update_custom_recipes(stack_name, layer_name, event_name, *recipes)
68
+ stack = Stack.find(stack_name)
69
+ layer = Layer.find(stack, layer_name)
70
+ layer.update_custom_recipes(event_name.to_sym, recipes)
71
+ rescue Dumbwaiter::Stack::NotFound, Dumbwaiter::Layer::NotFound => e
72
+ raise Thor::Error.new(e.message)
73
+ end
74
+
57
75
  desc "stacks", "List all the stacks"
58
76
  def stacks
59
77
  Stack.all.each { |stack| Kernel.puts("#{stack.name}: #{stack.apps.map(&:name).join(', ')}") }
@@ -40,6 +40,17 @@ class Dumbwaiter::Layer
40
40
  )
41
41
  end
42
42
 
43
+ def custom_recipes
44
+ opsworks_layer.custom_recipes.to_hash
45
+ end
46
+
47
+ def update_custom_recipes(event_name, runlist)
48
+ opsworks.update_layer(
49
+ layer_id: id,
50
+ custom_recipes: custom_recipes.merge(event_name => runlist)
51
+ )
52
+ end
53
+
43
54
  def instances
44
55
  @instances ||= Dumbwaiter::Instance.all(self, opsworks)
45
56
  end
@@ -37,8 +37,8 @@ class Dumbwaiter::Mock
37
37
  app
38
38
  end
39
39
 
40
- def make_layer(stack = make_stack, id = make_id, shortname = Faker::Name.first_name.downcase)
41
- layer = OpenStruct.new(stack_id: stack.stack_id, layer_id: id, shortname: shortname)
40
+ def make_layer(stack = make_stack, id = make_id, shortname = Faker::Name.first_name.downcase, custom_recipes = {})
41
+ layer = OpenStruct.new(stack_id: stack.stack_id, layer_id: id, shortname: shortname, custom_recipes: make_custom_default_recipes.merge(custom_recipes))
42
42
  layers << layer
43
43
  layer
44
44
  end
@@ -64,6 +64,10 @@ class Dumbwaiter::Mock
64
64
 
65
65
  protected
66
66
 
67
+ def make_custom_default_recipes
68
+ {setup: [], configure: [], deploy: [], undeploy: [], shutdown:[]}
69
+ end
70
+
67
71
  def make_app_source(url, revision)
68
72
  OpenStruct.new(url: url, revision: revision)
69
73
  end
@@ -1,3 +1,3 @@
1
1
  module Dumbwaiter
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Dumbwaiter::Cli do
4
4
  let(:fake_opsworks) { Dumbwaiter::Mock.new }
5
5
  let!(:fake_stack) { fake_opsworks.make_stack("amazing", "ducks") }
6
- let!(:fake_layer) { fake_opsworks.make_layer(fake_stack, "mighty", "beans") }
6
+ let!(:fake_layer) { fake_opsworks.make_layer(fake_stack, "mighty", "beans", setup: %w[ham salami]) }
7
7
  let!(:fake_app) { fake_opsworks.make_app(fake_stack, "delightful", "reifel") }
8
8
 
9
9
  subject(:cli) { Dumbwaiter::Cli.new }
@@ -152,14 +152,60 @@ describe Dumbwaiter::Cli do
152
152
 
153
153
  context "when the layer does not exist" do
154
154
  it "blows up" do
155
- expect { cli.run_recipe("ducks", "brick", "meatballs") }.to raise_error(Thor::Error)
155
+ expect { cli.run_recipe("ducks", "brick", "setup") }.to raise_error(Thor::Error)
156
156
  end
157
157
  end
158
158
  end
159
159
 
160
160
  context "when the stack does not exist" do
161
161
  it "blows up" do
162
- expect { cli.run_recipe("toques", "beans", "meatballs") }.to raise_error(Thor::Error)
162
+ expect { cli.run_recipe("toques", "beans", "setup") }.to raise_error(Thor::Error)
163
+ end
164
+ end
165
+ end
166
+
167
+ describe "#custom_recipes" do
168
+ context "when the stack exists" do
169
+ context "when the layer exists" do
170
+ it "prints custom recipes for a layer event" do
171
+ Kernel.should_receive(:puts) { |m| m.should == "ham salami" }
172
+ cli.custom_recipes("ducks", "beans", "setup")
173
+ end
174
+ end
175
+
176
+ context "when the layer does not exist" do
177
+ it "blows up" do
178
+ expect { cli.custom_recipes("ducks", "brick", "setup") }.to raise_error(Thor::Error)
179
+ end
180
+ end
181
+ end
182
+
183
+ context "when the stack does not exist" do
184
+ it "blows up" do
185
+ expect { cli.custom_recipes("toques", "beans", "setup") }.to raise_error(Thor::Error)
186
+ end
187
+ end
188
+ end
189
+
190
+ describe "#update_custom_recipes" do
191
+ context "when the stack exists" do
192
+ context "when the layer exists" do
193
+ it "updates custom recipes on the layer for the event" do
194
+ Dumbwaiter::Layer.any_instance.should_receive(:update_custom_recipes).with(:setup, ["eggs"])
195
+ cli.update_custom_recipes("ducks", "beans", "setup", "eggs")
196
+ end
197
+ end
198
+
199
+ context "when the layer does not exist" do
200
+ it "blows up" do
201
+ expect { cli.update_custom_recipes("ducks", "brick", "meatballs") }.to raise_error(Thor::Error)
202
+ end
203
+ end
204
+ end
205
+
206
+ context "when the stack does not exist" do
207
+ it "blows up" do
208
+ expect { cli.update_custom_recipes("toques", "beans", "meatballs") }.to raise_error(Thor::Error)
163
209
  end
164
210
  end
165
211
  end
@@ -5,7 +5,7 @@ describe Dumbwaiter::Deployment do
5
5
  let(:fake_stack) { fake_opsworks.make_stack("pancakes") }
6
6
  let(:fake_app) { fake_opsworks.make_app(fake_stack, "yo") }
7
7
  let!(:fake_user_profile) { fake_opsworks.make_user_profile("ie", "goose") }
8
- let(:custom_json) { JSON.dump(deploy: {"hockey" => {scm: {revision: "eh-buddy"}}}) }
8
+ let(:custom_json) { Dumbwaiter::DeploymentCustomJson.create("hockey", "eh-buddy").to_json }
9
9
  let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy", "badical", custom_json, DateTime.parse("last Tuesday").to_s, "ie", "i love sports") }
10
10
  let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
11
11
 
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Dumbwaiter::Layer do
4
4
  let(:fake_opsworks) { Dumbwaiter::Mock.new }
5
5
  let(:fake_stack) { fake_opsworks.make_stack("pancakes") }
6
- let(:fake_layer) { fake_opsworks.make_layer(fake_stack, "pinto", "meaty") }
6
+ let(:fake_layer) { fake_opsworks.make_layer(fake_stack, "pinto", "meaty", setup: ["ham"]) }
7
7
  let!(:fake_instance) { fake_opsworks.make_instance(fake_layer, fake_stack, "dragons") }
8
8
 
9
9
  let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
@@ -13,6 +13,7 @@ describe Dumbwaiter::Layer do
13
13
  its(:opsworks_layer) { should == fake_layer }
14
14
  its(:id) { should == "pinto" }
15
15
  its(:shortname) { should == "meaty" }
16
+ its(:custom_recipes) { should include(setup: ["ham"]) }
16
17
 
17
18
  it { should have(1).instances }
18
19
 
@@ -51,4 +52,21 @@ describe Dumbwaiter::Layer do
51
52
  layer.run_recipe("meatballs")
52
53
  end
53
54
  end
55
+
56
+ describe "#update_custom_recipes" do
57
+ it "overwrites existing custom recipes for an event" do
58
+ fake_opsworks.should_receive(:update_layer) do |params|
59
+ params[:layer_id].should == "pinto"
60
+ params[:custom_recipes].should include(setup: ["feet"])
61
+ end
62
+ layer.update_custom_recipes(:setup, ["feet"])
63
+ end
64
+
65
+ it "preserves existing custom recipes for an event when updating another event" do
66
+ fake_opsworks.should_receive(:update_layer) do |params|
67
+ params[:custom_recipes].should include(setup: ["ham"])
68
+ end
69
+ layer.update_custom_recipes(:deploy, ["feet"])
70
+ end
71
+ end
54
72
  end
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,7 @@ require "dumbwaiter"
5
5
  require "dumbwaiter/mock"
6
6
 
7
7
  Aws.config = {access_key_id: "tacos", secret_access_key: "secret chocolate"}
8
+ I18n.enforce_available_locales = false
8
9
 
9
10
  # This file was generated by the `rspec --init` command. Conventionally, all
10
11
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumbwaiter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doc Ritezel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-23 00:00:00.000000000 Z
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core