dumbwaiter 0.4.3 → 0.5.0

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: d982d2f214ae14a68e7580cf7fce7ac5c5faab5b
4
- data.tar.gz: 8c61bcff1b9d5bba3837d0bed4b321758a49e9a3
3
+ metadata.gz: dcaf684002c436fa32d8091bbc6bfc5058d244cd
4
+ data.tar.gz: 6118f4b3bb27ca9f007c6421b518e3a9cac822ac
5
5
  SHA512:
6
- metadata.gz: 14c30206fe158fb0da5ef33b546070bc59d14def43685b256bf08334d33648ae34dead8915ae60072bcf4a70a242d6d5d274b704050baf35dc06ddadb634fd2c
7
- data.tar.gz: d49f8e84274ffbe8e490cd3e2da8a552ebfa310e16dacd31457a949dac7c2188ad882fcf56834a03da343523fccc10e8ad0030d24c34eaf1a4cdedf8f6795a9e
6
+ metadata.gz: 6f73d6c80660e706b578b01648595fc33af488f9891a877f66d210c4d75bbfec7f84f9361e88ef02f2a125b2053c8327df5e63b74f0da84f6bb4e33fbda1a4a8
7
+ data.tar.gz: 0226c5b905d5bb1b872691123bb514c4cab48ca57a3888adb4ba4e283588d4914c8efad029ecab0106930fd21b0e019c532c0672ba6842c9f2057e1740af110c
@@ -1 +1 @@
1
- 2.0.0-p353
1
+ 2.1.0
@@ -1,4 +1,5 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - 2.1.0
4
5
  script: script/ci.sh
@@ -58,7 +58,8 @@ module Dumbwaiter
58
58
  def custom_recipes(stack_name, layer_name, event_name)
59
59
  stack = Stack.find(stack_name)
60
60
  layer = Layer.find(stack, layer_name)
61
- Kernel.puts(layer.custom_recipes[event_name.to_sym].join(" "))
61
+ recipes = layer.custom_recipes.fetch(event_name, []).join(" ")
62
+ Kernel.puts(recipes)
62
63
  rescue Dumbwaiter::Stack::NotFound, Dumbwaiter::Layer::NotFound => e
63
64
  raise Thor::Error.new(e.message)
64
65
  end
@@ -31,7 +31,7 @@ class Dumbwaiter::Deployment
31
31
  end
32
32
 
33
33
  def user_name
34
- if opsworks_deployment.iam_user_arn.nil? || user_profile.nil?
34
+ if user_profile.nil?
35
35
  "OpsWorks"
36
36
  else
37
37
  user_profile.name
@@ -1,8 +1,14 @@
1
+ require "ostruct"
1
2
  require "faker"
2
3
 
3
4
  class Dumbwaiter::Mock
4
5
  attr_reader :stacks, :deployments, :apps, :layers, :instances, :user_profiles
5
6
 
7
+ class HashWithIndifferentAccess < Hash
8
+ include Hashie::Extensions::MergeInitializer
9
+ include Hashie::Extensions::IndifferentAccess
10
+ end
11
+
6
12
  def opsworks; self; end
7
13
  def describe_stacks(*_); OpenStruct.new(stacks: stacks); end
8
14
  def describe_deployments(*_); OpenStruct.new(deployments: deployments); end
@@ -21,57 +27,84 @@ class Dumbwaiter::Mock
21
27
  end
22
28
 
23
29
  def initialize
24
- super
25
30
  clear
26
31
  end
27
32
 
28
- def make_stack(id = make_id, name = Faker::Name.first_name, color = make_color)
29
- stack = OpenStruct.new(stack_id: id, name: name, attributes: {"Color" => color})
33
+ def create_stack(params = {})
34
+ params[:name] ||= Faker::Name.first_name
35
+ params[:attributes] ||= {}
36
+ params[:attributes]["Color"] ||= make_color
37
+ stack = OpenStruct.new(params.merge(stack_id: make_id))
30
38
  stacks << stack
31
39
  stack
32
40
  end
33
41
 
34
- def make_app(stack = make_stack, id = make_id, name = Faker::Name.first_name, url = Faker::Internet.url, revision = make_revision)
35
- app = OpenStruct.new(stack_id: stack.stack_id, app_id: id, name: name, app_source: make_app_source(url, revision))
42
+ def create_app(params = {})
43
+ params[:stack_id] ||= create_stack.stack_id
44
+ params[:name] ||= Faker::Name.last_name
45
+ params[:shortname] ||= Faker::Name.first_name.downcase
46
+ params[:app_source] = Hashie::Mash.new(params.fetch(:app_source, {}))
47
+ params[:app_source][:url] ||= Faker::Internet.url
48
+ params[:app_source][:revision] = params[:app_source].fetch(:revision, make_revision)
49
+ app = OpenStruct.new(params.merge(app_id: make_id))
36
50
  apps << app
37
51
  app
38
52
  end
39
53
 
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))
54
+ def create_layer(params = {})
55
+ params[:stack_id] ||= create_stack.stack_id
56
+ params[:name] ||= Faker::Name.last_name
57
+ params[:shortname] ||= Faker::Name.first_name.downcase
58
+ params[:custom_recipes] = HashWithIndifferentAccess.new(params[:custom_recipes] || {})
59
+ params[:custom_recipes] = HashWithIndifferentAccess.new(setup: [], configure: [], deploy: [], undeploy: [], shutdown:[]).merge(params[:custom_recipes])
60
+ params[:type] ||= %w[lb web php-app rails-app nodejs-app memcached db-master monitoring-master custom].sample
61
+ layer = OpenStruct.new(params.merge(layer_id: make_id))
42
62
  layers << layer
43
63
  layer
44
64
  end
45
65
 
46
- def make_deployment(stack = make_stack, app = make_app, id = make_id, command_name = Faker::Name.first_name.downcase, status = Faker::Name.first_name, custom_json = "{}", at = Time.now.to_s, arn = Faker::Name.first_name, comment = Faker::Company.bs)
47
- command = OpenStruct.new(name: command_name)
48
- deployment = OpenStruct.new(stack_id: stack.stack_id, app_id: app.app_id, deployment_id: id, command: command, created_at: at, status: status, comment: comment, iam_user_arn: arn, custom_json: custom_json)
66
+ def create_deployment(params = {})
67
+ params[:stack_id] ||= create_stack.stack_id
68
+ params[:app_id] ||= create_app.app_id
69
+ params[:command] = Hashie::Mash.new(params.fetch(:command, {}))
70
+ params[:command][:name] ||= %w[install_dependencies update_dependencies update_custom_cookbooks execute_recipes deploy rollback start stop restart undeploy].sample
71
+ params[:custom_json] ||= "{}"
72
+ params[:comment] ||= Faker::Company.bs
73
+ params[:iam_user_arn] = params.fetch(:iam_user_arn, create_user_profile.iam_user_arn)
74
+ params[:created_at] ||= Time.now.to_s
75
+ params[:status] ||= %w[running failed successful].sample
76
+ deployment = OpenStruct.new(params.merge(deployment_id: make_id))
49
77
  deployments << deployment
50
78
  deployment
51
79
  end
52
80
 
53
- def make_instance(stack = make_stack, layer = make_layer, id = make_id)
54
- instance = OpenStruct.new(layer_id: layer.layer_id, stack_id: stack.stack_id, instance_id: id)
81
+ def create_instance(params = {})
82
+ params[:stack_id] ||= create_stack.stack_id
83
+ params[:layer_id] ||= create_layer.layer_id
84
+ instance = OpenStruct.new(params.merge(instance_id: make_id))
85
+ instances << instance
86
+ instance
87
+ end
88
+
89
+ def create_instance(params = {})
90
+ params[:stack_id] ||= create_stack.stack_id
91
+ params[:layer_id] ||= create_layer.layer_id
92
+ instance = OpenStruct.new(params.merge(instance_id: make_id))
55
93
  instances << instance
56
94
  instance
57
95
  end
58
96
 
59
- def make_user_profile(id = Faker::Name.last_name.downcase, name = Faker::Name.first_name)
60
- user_profile = OpenStruct.new(aws_iam_arn: id, name: name)
97
+ def create_user_profile(params = {})
98
+ params[:iam_user_arn] ||= Faker::Name.first_name.downcase
99
+ params[:ssh_username] ||= Faker::Name.first_name.downcase
100
+ params[:name] ||= Faker::Name.first_name.downcase
101
+ user_profile = OpenStruct.new(params)
61
102
  user_profiles << user_profile
62
103
  user_profile
63
104
  end
64
105
 
65
106
  protected
66
107
 
67
- def make_custom_default_recipes
68
- {setup: [], configure: [], deploy: [], undeploy: [], shutdown:[]}
69
- end
70
-
71
- def make_app_source(url, revision)
72
- OpenStruct.new(url: url, revision: revision)
73
- end
74
-
75
108
  def make_revision
76
109
  "%06x" % (rand * 0xffffff)
77
110
  end
@@ -6,7 +6,10 @@ class Dumbwaiter::UserProfile
6
6
  end
7
7
 
8
8
  def self.find(iam_user_arn, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
9
- cache[iam_user_arn] ||= opsworks.describe_user_profiles(iam_user_arns: [iam_user_arn]).user_profiles.first
9
+ unless cache.has_key?(iam_user_arn)
10
+ cache[iam_user_arn] = opsworks.describe_user_profiles(iam_user_arns: [iam_user_arn]).user_profiles.detect { |p| p.iam_user_arn == iam_user_arn }
11
+ end
12
+ cache[iam_user_arn]
10
13
  end
11
14
 
12
15
  def initialize(opsworks_user_profile, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
@@ -1,3 +1,3 @@
1
1
  module Dumbwaiter
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -2,25 +2,27 @@ require "spec_helper"
2
2
 
3
3
  describe Dumbwaiter::App do
4
4
  let(:fake_opsworks) { Dumbwaiter::Mock.new }
5
- let(:fake_stack) { fake_opsworks.make_stack("pancakes") }
6
- let!(:fake_app) { fake_opsworks.make_app(fake_stack, "amazing", "goose", "git@example.com:tacos/great.git") }
5
+ let(:fake_stack) { fake_opsworks.create_stack }
6
+ let(:fake_custom_recipes) { {setup: ["ham"]} }
7
+ let(:app_source) { Hashie::Mash.new(url: "git@example.com:tacos/great.git") }
8
+ let!(:fake_app) { fake_opsworks.create_app(stack_id: fake_stack.stack_id, name: "goose", app_source: app_source) }
7
9
  let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
8
10
 
9
11
  subject(:app) { Dumbwaiter::App.new(real_stack, fake_app, fake_opsworks) }
10
12
 
11
- its(:id) { should == "amazing" }
13
+ its(:id) { should == fake_app.app_id }
12
14
  its(:name) { should == "goose" }
13
15
  its(:url) { should == "git@example.com:tacos/great.git" }
14
16
 
15
17
  describe "#revision" do
16
18
  context "when there is no revision specified" do
17
- let(:fake_app) { fake_opsworks.make_app(fake_stack, "amazing", "goose", "git@example.com:tacos/great.git", nil) }
19
+ let(:app_source) { {url: "git@example.com:tacos/great.git", revision: nil} }
18
20
 
19
21
  its(:revision) { should == "master" }
20
22
  end
21
23
 
22
24
  context "when a revision is specified" do
23
- let(:fake_app) { fake_opsworks.make_app(fake_stack, "amazing", "goose", "git@example.com:tacos/great.git", "wat") }
25
+ let(:app_source) { {url: "git@example.com:tacos/great.git", revision: "wat"} }
24
26
 
25
27
  its(:revision) { should == "wat" }
26
28
  end
@@ -30,8 +32,8 @@ describe Dumbwaiter::App do
30
32
  context "when no revision is specified" do
31
33
  it "creates a deployment" do
32
34
  fake_opsworks.should_receive(:create_deployment) do |params|
33
- params[:stack_id].should == "pancakes"
34
- params[:app_id].should == "amazing"
35
+ params[:stack_id].should == fake_stack.stack_id
36
+ params[:app_id].should == fake_app.app_id
35
37
  params[:command].should == {name: "deploy", args: {migrate: ["true"]}}
36
38
  end
37
39
  app.deploy
@@ -51,8 +53,8 @@ describe Dumbwaiter::App do
51
53
  describe "#rollback" do
52
54
  it "creates a rollback" do
53
55
  fake_opsworks.should_receive(:create_deployment) do |params|
54
- params[:stack_id].should == "pancakes"
55
- params[:app_id].should == "amazing"
56
+ params[:stack_id].should == fake_stack.stack_id
57
+ params[:app_id].should == fake_app.app_id
56
58
  params[:command].should == {name: "rollback"}
57
59
  end
58
60
  app.rollback
@@ -61,7 +63,7 @@ describe Dumbwaiter::App do
61
63
 
62
64
  describe ".all" do
63
65
  it "fetches all the apps" do
64
- fake_opsworks.should_receive(:describe_apps).with(stack_id: "pancakes").and_call_original
66
+ fake_opsworks.should_receive(:describe_apps).with(stack_id: fake_stack.stack_id).and_call_original
65
67
  Dumbwaiter::App.all(real_stack, fake_opsworks).should have(1).app
66
68
  end
67
69
  end
@@ -69,7 +71,7 @@ describe Dumbwaiter::App do
69
71
  describe ".find" do
70
72
  context "when the app exists" do
71
73
  it "finds the app by name" do
72
- Dumbwaiter::App.find(real_stack, "goose", fake_opsworks).id.should == "amazing"
74
+ Dumbwaiter::App.find(real_stack, "goose", fake_opsworks).id.should == fake_app.app_id
73
75
  end
74
76
  end
75
77
 
@@ -85,7 +87,7 @@ describe Dumbwaiter::App do
85
87
  describe ".find" do
86
88
  context "when the app exists" do
87
89
  it "finds the app by id" do
88
- Dumbwaiter::App.find_by_id(real_stack, "amazing", fake_opsworks).name.should == "goose"
90
+ Dumbwaiter::App.find_by_id(real_stack, fake_app.app_id, fake_opsworks).name.should == "goose"
89
91
  end
90
92
  end
91
93
 
@@ -2,9 +2,9 @@ require "spec_helper"
2
2
 
3
3
  describe Dumbwaiter::Cli do
4
4
  let(:fake_opsworks) { Dumbwaiter::Mock.new }
5
- let!(:fake_stack) { fake_opsworks.make_stack("amazing", "ducks") }
6
- let!(:fake_layer) { fake_opsworks.make_layer(fake_stack, "mighty", "beans", setup: %w[ham salami]) }
7
- let!(:fake_app) { fake_opsworks.make_app(fake_stack, "delightful", "reifel") }
5
+ let!(:fake_stack) { fake_opsworks.create_stack }
6
+ let!(:fake_layer) { fake_opsworks.create_layer(stack_id: fake_stack.stack_id, custom_recipes: {setup: %w[ham salami]}) }
7
+ let!(:fake_app) { fake_opsworks.create_app(stack_id: fake_stack.stack_id) }
8
8
 
9
9
  subject(:cli) { Dumbwaiter::Cli.new }
10
10
 
@@ -15,20 +15,20 @@ describe Dumbwaiter::Cli do
15
15
  context "when the app exists" do
16
16
  it "deploys the stack with the resolved id" do
17
17
  Dumbwaiter::App.any_instance.should_receive(:deploy).with("corn")
18
- cli.deploy("ducks", "reifel", "corn")
18
+ cli.deploy(fake_stack.name, fake_app.name, "corn")
19
19
  end
20
20
  end
21
21
 
22
22
  context "when the app does not exist" do
23
23
  it "blows up" do
24
- expect { cli.deploy("ducks", "squirrel", "corn") }.to raise_error(Thor::Error)
24
+ expect { cli.deploy(fake_stack.name, "squirrel", "corn") }.to raise_error(Thor::Error)
25
25
  end
26
26
  end
27
27
  end
28
28
 
29
29
  context "when the stack does not exist" do
30
30
  it "blows up" do
31
- expect { cli.deploy("toques", "reifel", "corn") }.to raise_error(Thor::Error)
31
+ expect { cli.deploy("toques", fake_app.name, "corn") }.to raise_error(Thor::Error)
32
32
  end
33
33
  end
34
34
  end
@@ -38,20 +38,20 @@ describe Dumbwaiter::Cli do
38
38
  context "when the app exists" do
39
39
  it "deploys the stack with the resolved id" do
40
40
  Dumbwaiter::App.any_instance.should_receive(:rollback)
41
- cli.rollback("ducks", "reifel")
41
+ cli.rollback(fake_stack.name, fake_app.name)
42
42
  end
43
43
  end
44
44
 
45
45
  context "when the app does not exist" do
46
46
  it "blows up" do
47
- expect { cli.rollback("ducks", "montreal") }.to raise_error(Thor::Error)
47
+ expect { cli.rollback(fake_stack.name, "montreal") }.to raise_error(Thor::Error)
48
48
  end
49
49
  end
50
50
  end
51
51
 
52
52
  context "when the stack does not exist" do
53
53
  it "blows up" do
54
- expect { cli.rollback("maple syrup", "reifel") }.to raise_error(Thor::Error)
54
+ expect { cli.rollback("maple syrup", fake_app.name) }.to raise_error(Thor::Error)
55
55
  end
56
56
  end
57
57
  end
@@ -59,47 +59,47 @@ describe Dumbwaiter::Cli do
59
59
  describe "#list" do
60
60
  context "when the stack exists" do
61
61
  context "when the deployment is a rollback" do
62
- before { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "rollback") }
62
+ before { fake_opsworks.create_deployment(stack_id: fake_stack.stack_id, command: {name: "rollback"}) }
63
63
 
64
64
  it "lists the deployment" do
65
65
  Kernel.should_receive(:puts) { |m| m.should =~ /rollback/ }
66
- cli.list("ducks")
66
+ cli.list(fake_stack.name)
67
67
  end
68
68
  end
69
69
 
70
70
  context "when the deployment is a deploy" do
71
- before { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy") }
71
+ before { fake_opsworks.create_deployment(stack_id: fake_stack.stack_id, command: {name: "deploy"}) }
72
72
 
73
73
  it "lists the deployment" do
74
74
  Kernel.should_receive(:puts) { |m| m.should =~ /deploy/ }
75
- cli.list("ducks")
75
+ cli.list(fake_stack.name)
76
76
  end
77
77
  end
78
78
 
79
79
  context "when the deployment is a custom cookbook update" do
80
- before { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "update_custom_cookbooks") }
80
+ before { fake_opsworks.create_deployment(stack_id: fake_stack.stack_id, command: {name: "update_custom_cookbooks"}) }
81
81
 
82
82
  it "lists the deployment" do
83
83
  Kernel.should_receive(:puts) { |m| m.should =~ /update_custom_cookbooks/ }
84
- cli.list("ducks")
84
+ cli.list(fake_stack.name)
85
85
  end
86
86
  end
87
87
 
88
88
  context "when the deployment is a recipe execution" do
89
- before { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "execute_recipes") }
89
+ before { fake_opsworks.create_deployment(stack_id: fake_stack.stack_id, command: {name: "execute_recipes"}) }
90
90
 
91
91
  it "lists the deployment" do
92
92
  Kernel.should_receive(:puts) { |m| m.should =~ /execute_recipes/ }
93
- cli.list("ducks")
93
+ cli.list(fake_stack.name)
94
94
  end
95
95
  end
96
96
 
97
97
  context "when the deployment is something else" do
98
- let(:fake_deployment) { double(:deployment, command_name: "gargle", to_log: "brblrgl") }
98
+ before { fake_opsworks.create_deployment(stack_id: fake_stack.stack_id, command: {name: "wat"}) }
99
99
 
100
100
  it "does not print anything" do
101
101
  Kernel.should_not_receive(:puts)
102
- cli.list("ducks")
102
+ cli.list(fake_stack.name)
103
103
  end
104
104
  end
105
105
  end
@@ -113,11 +113,11 @@ describe Dumbwaiter::Cli do
113
113
 
114
114
  describe "#layers" do
115
115
  context "when the stack exists" do
116
- before { fake_opsworks.make_layer(fake_stack, "handsome", "frijoles") }
116
+ before { fake_opsworks.create_layer(stack_id: fake_stack.stack_id, shortname: "frijoles") }
117
117
 
118
118
  it "lists the layers" do
119
- Kernel.should_receive(:puts).with("beans frijoles")
120
- cli.layers("ducks")
119
+ Kernel.should_receive(:puts).with("#{fake_layer.shortname} frijoles")
120
+ cli.layers(fake_stack.name)
121
121
  end
122
122
  end
123
123
 
@@ -132,7 +132,7 @@ describe Dumbwaiter::Cli do
132
132
  context "when the stack exists" do
133
133
  it "deploys the stack with the resolved id" do
134
134
  Dumbwaiter::Stack.any_instance.should_receive(:rechef)
135
- cli.rechef("ducks")
135
+ cli.rechef(fake_stack.name)
136
136
  end
137
137
  end
138
138
 
@@ -148,20 +148,20 @@ describe Dumbwaiter::Cli do
148
148
  context "when the layer exists" do
149
149
  it "runs the recipe on the layer" do
150
150
  Dumbwaiter::Layer.any_instance.should_receive(:run_recipe).with("meatballs")
151
- cli.run_recipe("ducks", "beans", "meatballs")
151
+ cli.run_recipe(fake_stack.name, fake_layer.shortname, "meatballs")
152
152
  end
153
153
  end
154
154
 
155
155
  context "when the layer does not exist" do
156
156
  it "blows up" do
157
- expect { cli.run_recipe("ducks", "brick", "setup") }.to raise_error(Thor::Error)
157
+ expect { cli.run_recipe(fake_stack.name, "brick", "setup") }.to raise_error(Thor::Error)
158
158
  end
159
159
  end
160
160
  end
161
161
 
162
162
  context "when the stack does not exist" do
163
163
  it "blows up" do
164
- expect { cli.run_recipe("toques", "beans", "setup") }.to raise_error(Thor::Error)
164
+ expect { cli.run_recipe("toques", fake_layer.shortname, "setup") }.to raise_error(Thor::Error)
165
165
  end
166
166
  end
167
167
  end
@@ -171,20 +171,20 @@ describe Dumbwaiter::Cli do
171
171
  context "when the layer exists" do
172
172
  it "prints custom recipes for a layer event" do
173
173
  Kernel.should_receive(:puts).with("ham salami")
174
- cli.custom_recipes("ducks", "beans", "setup")
174
+ cli.custom_recipes(fake_stack.name, fake_layer.shortname, "setup")
175
175
  end
176
176
  end
177
177
 
178
178
  context "when the layer does not exist" do
179
179
  it "blows up" do
180
- expect { cli.custom_recipes("ducks", "brick", "setup") }.to raise_error(Thor::Error)
180
+ expect { cli.custom_recipes(fake_stack.name, "brick", "setup") }.to raise_error(Thor::Error)
181
181
  end
182
182
  end
183
183
  end
184
184
 
185
185
  context "when the stack does not exist" do
186
186
  it "blows up" do
187
- expect { cli.custom_recipes("toques", "beans", "setup") }.to raise_error(Thor::Error)
187
+ expect { cli.custom_recipes("toques", fake_layer.shortname, "setup") }.to raise_error(Thor::Error)
188
188
  end
189
189
  end
190
190
  end
@@ -194,27 +194,27 @@ describe Dumbwaiter::Cli do
194
194
  context "when the layer exists" do
195
195
  it "updates custom recipes on the layer for the event" do
196
196
  Dumbwaiter::Layer.any_instance.should_receive(:update_custom_recipes).with(:setup, ["eggs"])
197
- cli.update_custom_recipes("ducks", "beans", "setup", "eggs")
197
+ cli.update_custom_recipes(fake_stack.name, fake_layer.shortname, "setup", "eggs")
198
198
  end
199
199
  end
200
200
 
201
201
  context "when the layer does not exist" do
202
202
  it "blows up" do
203
- expect { cli.update_custom_recipes("ducks", "brick", "meatballs") }.to raise_error(Thor::Error)
203
+ expect { cli.update_custom_recipes(fake_stack.name, "brick", "meatballs") }.to raise_error(Thor::Error)
204
204
  end
205
205
  end
206
206
  end
207
207
 
208
208
  context "when the stack does not exist" do
209
209
  it "blows up" do
210
- expect { cli.update_custom_recipes("toques", "beans", "meatballs") }.to raise_error(Thor::Error)
210
+ expect { cli.update_custom_recipes("toques", fake_layer.shortname, "meatballs") }.to raise_error(Thor::Error)
211
211
  end
212
212
  end
213
213
  end
214
214
 
215
215
  describe "#stacks" do
216
216
  it "lists the stacks" do
217
- Kernel.should_receive(:puts).with("ducks: reifel")
217
+ Kernel.should_receive(:puts).with("#{fake_stack.name}: #{fake_app.name}")
218
218
  cli.stacks
219
219
  end
220
220
  end
@@ -2,11 +2,27 @@ require "spec_helper"
2
2
 
3
3
  describe Dumbwaiter::Deployment do
4
4
  let(:fake_opsworks) { Dumbwaiter::Mock.new }
5
- let(:fake_stack) { fake_opsworks.make_stack("pancakes") }
6
- let(:fake_app) { fake_opsworks.make_app(fake_stack, "yo") }
7
- let!(:fake_user_profile) { fake_opsworks.make_user_profile("ie", "goose") }
5
+ let(:fake_stack) { fake_opsworks.create_stack }
6
+ let(:fake_app) { fake_opsworks.create_app(stack_id: fake_stack.stack_id) }
7
+ let!(:fake_user_profile) { fake_opsworks.create_user_profile(name: "goose") }
8
8
  let(:custom_json) { Dumbwaiter::DeploymentCustomJson.create("hockey", "eh-buddy").to_json }
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") }
9
+ let(:deployment_params) do
10
+ {
11
+ command: {name: "deploy"},
12
+ status: "badical",
13
+ comment: "i love sports",
14
+ created_at: DateTime.parse("last Tuesday").to_s
15
+ }
16
+ end
17
+
18
+ let!(:fake_deployment) do
19
+ fake_opsworks.create_deployment({
20
+ iam_user_arn: fake_user_profile.iam_user_arn,
21
+ stack_id: fake_stack.stack_id,
22
+ app_id: fake_app.app_id,
23
+ custom_json: custom_json
24
+ }.merge(deployment_params))
25
+ end
10
26
  let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
11
27
 
12
28
  subject(:deployment) { Dumbwaiter::Deployment.new(real_stack, fake_deployment, fake_opsworks) }
@@ -23,35 +39,47 @@ describe Dumbwaiter::Deployment do
23
39
  end
24
40
 
25
41
  context "when the command name is not deploy" do
26
- let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "floss", "badical", custom_json, DateTime.parse("last Tuesday").to_s, "ie", "i love sports") }
42
+ let(:deployment_params) do
43
+ {
44
+ command: {name: "floss"},
45
+ status: "badical",
46
+ created_at: DateTime.parse("last Tuesday").to_s
47
+ }
48
+ end
27
49
 
28
50
  its(:to_log) { should == "#{DateTime.parse("last Tuesday")} - goose - floss - badical" }
29
51
  end
30
52
 
31
- context "when the iam user arn is nil" do
32
- let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy", "badical", custom_json, DateTime.parse("last Tuesday").to_s, nil, "i love sports") }
33
-
34
- its(:user_name) { should == "OpsWorks" }
35
- end
36
-
37
- context "when the iam user arn does not exist" do
38
- let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy", "badical", custom_json, DateTime.parse("last Tuesday").to_s, "wait which user is this", "i love sports") }
39
-
40
- before { fake_opsworks.clear }
53
+ context "when the iam user does not exist" do
54
+ let(:deployment_params) do
55
+ {
56
+ command: {name: "floss"},
57
+ status: "badical",
58
+ created_at: DateTime.parse("last Tuesday").to_s,
59
+ iam_user_arn: nil
60
+ }
61
+ end
41
62
 
42
63
  its(:user_name) { should == "OpsWorks" }
43
64
  end
44
65
 
45
66
  context "when custom_json is nil" do
46
67
  let(:real_app) { Dumbwaiter::App.new(real_stack, fake_app, fake_opsworks) }
47
- let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy", "badical", nil, DateTime.parse("last Tuesday").to_s, "ie", "i love sports") }
68
+ let(:deployment_params) do
69
+ {
70
+ command: {name: "floss"},
71
+ status: "badical",
72
+ created_at: DateTime.parse("last Tuesday").to_s,
73
+ custom_json: nil
74
+ }
75
+ end
48
76
 
49
77
  its(:revision) { should == "#{real_app.revision}@{#{DateTime.parse("last Tuesday")}}" }
50
78
  end
51
79
 
52
80
  describe ".all" do
53
81
  it "fetches all the deployments" do
54
- fake_opsworks.should_receive(:describe_deployments).with(stack_id: "pancakes").and_call_original
82
+ fake_opsworks.should_receive(:describe_deployments).with(stack_id: fake_stack.stack_id).and_call_original
55
83
  Dumbwaiter::Deployment.all(real_stack, fake_opsworks).should have(1).deployment
56
84
  end
57
85
  end
@@ -2,9 +2,9 @@ require "spec_helper"
2
2
 
3
3
  describe Dumbwaiter::Instance do
4
4
  let(:fake_opsworks) { Dumbwaiter::Mock.new }
5
- let(:fake_stack) { fake_opsworks.make_stack }
6
- let(:fake_layer) { fake_opsworks.make_layer(fake_stack) }
7
- let!(:fake_instance) { fake_opsworks.make_instance(fake_stack, fake_layer) }
5
+ let(:fake_stack) { fake_opsworks.create_stack }
6
+ let(:fake_layer) { fake_opsworks.create_layer }
7
+ let!(:fake_instance) { fake_opsworks.create_instance(stack_id: fake_stack.stack_id, layer_id: fake_layer.layer_id) }
8
8
 
9
9
  subject(:instance) { Dumbwaiter::Instance.new(fake_layer, fake_instance, fake_opsworks) }
10
10
 
@@ -2,16 +2,17 @@ require "spec_helper"
2
2
 
3
3
  describe Dumbwaiter::Layer do
4
4
  let(:fake_opsworks) { Dumbwaiter::Mock.new }
5
- let(:fake_stack) { fake_opsworks.make_stack("pancakes") }
6
- let(:fake_layer) { fake_opsworks.make_layer(fake_stack, "pinto", "meaty", setup: ["ham"]) }
7
- let!(:fake_instance) { fake_opsworks.make_instance(fake_layer, fake_stack, "dragons") }
5
+ let(:fake_stack) { fake_opsworks.create_stack }
6
+ let(:fake_custom_recipes) { {setup: ["ham"]} }
7
+ let(:fake_layer) { fake_opsworks.create_layer(stack_id: fake_stack.stack_id, shortname: "meaty", custom_recipes: fake_custom_recipes) }
8
+ let!(:fake_instance) { fake_opsworks.create_instance }
8
9
 
9
10
  let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
10
11
 
11
12
  subject(:layer) { Dumbwaiter::Layer.new(real_stack, fake_layer, fake_opsworks) }
12
13
 
13
14
  its(:opsworks_layer) { should == fake_layer }
14
- its(:id) { should == "pinto" }
15
+ its(:id) { should == fake_layer.layer_id }
15
16
  its(:shortname) { should == "meaty" }
16
17
  its(:custom_recipes) { should include(setup: ["ham"]) }
17
18
 
@@ -21,13 +22,15 @@ describe Dumbwaiter::Layer do
21
22
  let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
22
23
 
23
24
  it "fetches all the deployments" do
24
- fake_opsworks.should_receive(:describe_layers).with(stack_id: "pancakes").and_call_original
25
+ fake_opsworks.should_receive(:describe_layers).with(stack_id: fake_stack.stack_id).and_call_original
25
26
  Dumbwaiter::Layer.all(real_stack, fake_opsworks).should have(1).layer
26
27
  end
27
28
  end
28
29
 
29
30
  describe ".find" do
30
31
  context "when the layer exists" do
32
+ let!(:layer) { Dumbwaiter::Layer.new(real_stack, fake_layer, fake_opsworks) }
33
+
31
34
  it "finds the layer by name" do
32
35
  Dumbwaiter::Layer.find(real_stack, "meaty", fake_opsworks).shortname.should == "meaty"
33
36
  end
@@ -45,8 +48,8 @@ describe Dumbwaiter::Layer do
45
48
  describe "#run_recipe" do
46
49
  it "executes a recipe" do
47
50
  fake_opsworks.should_receive(:create_deployment) do |params|
48
- params[:stack_id].should == "pancakes"
49
- params[:instance_ids].should == ["dragons"]
51
+ params[:stack_id].should == fake_stack.stack_id
52
+ params[:instance_ids].should == [fake_instance.instance_id]
50
53
  params[:command].should == {name: "execute_recipes", args: {recipes: ["meatballs"]}}
51
54
  end
52
55
  layer.run_recipe("meatballs")
@@ -56,7 +59,7 @@ describe Dumbwaiter::Layer do
56
59
  describe "#update_custom_recipes" do
57
60
  it "overwrites existing custom recipes for an event" do
58
61
  fake_opsworks.should_receive(:update_layer) do |params|
59
- params[:layer_id].should == "pinto"
62
+ params[:layer_id].should == fake_layer.layer_id
60
63
  params[:custom_recipes].should include(setup: ["feet"])
61
64
  end
62
65
  layer.update_custom_recipes(:setup, ["feet"])
@@ -2,10 +2,10 @@ require "spec_helper"
2
2
 
3
3
  describe Dumbwaiter::Stack do
4
4
  let(:fake_opsworks) { Dumbwaiter::Mock.new }
5
- let!(:fake_stack) { fake_opsworks.make_stack("cool", "ducks", "hot pink") }
6
- let!(:fake_app) { fake_opsworks.make_app(fake_stack) }
7
- let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app) }
8
- let!(:fake_layer) { fake_opsworks.make_layer(fake_stack) }
5
+ let!(:fake_stack) { fake_opsworks.create_stack(name: "ducks", attributes:{"Color" => "hot pink"}) }
6
+ let!(:fake_app) { fake_opsworks.create_app(stack_id: fake_stack.stack_id) }
7
+ let!(:fake_deployment) { fake_opsworks.create_deployment(stack_id: fake_stack.stack_id, app_id: fake_app.app_id) }
8
+ let!(:fake_layer) { fake_opsworks.create_layer(stack_id: fake_stack.stack_id) }
9
9
 
10
10
  subject(:stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
11
11
 
@@ -13,7 +13,7 @@ describe Dumbwaiter::Stack do
13
13
  it { should have(1).deployments }
14
14
  it { should have(1).layers }
15
15
 
16
- its(:id) { should == "cool" }
16
+ its(:id) { should == fake_stack.stack_id }
17
17
  its(:name) { should == "ducks" }
18
18
  its(:color) { should == "hot pink" }
19
19
 
@@ -26,7 +26,7 @@ describe Dumbwaiter::Stack do
26
26
  describe ".find" do
27
27
  context "when the stack exists" do
28
28
  it "finds the stack by name" do
29
- Dumbwaiter::Stack.find("ducks", fake_opsworks).id.should == "cool"
29
+ Dumbwaiter::Stack.find("ducks", fake_opsworks).id.should == fake_stack.stack_id
30
30
  end
31
31
  end
32
32
 
@@ -42,7 +42,7 @@ describe Dumbwaiter::Stack do
42
42
  describe ".find_by_id" do
43
43
  context "when the stack exists" do
44
44
  it "finds the stack by id" do
45
- Dumbwaiter::Stack.find_by_id("cool", fake_opsworks).name.should == "ducks"
45
+ Dumbwaiter::Stack.find_by_id(fake_stack.stack_id, fake_opsworks).name.should == "ducks"
46
46
  end
47
47
  end
48
48
 
@@ -58,7 +58,7 @@ describe Dumbwaiter::Stack do
58
58
  describe "#rechef" do
59
59
  it "creates a deployment" do
60
60
  fake_opsworks.should_receive(:create_deployment) do |params|
61
- params[:stack_id].should == "cool"
61
+ params[:stack_id].should == fake_stack.stack_id
62
62
  params[:command].should == {name: "update_custom_cookbooks"}
63
63
  end
64
64
  stack.rechef
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumbwaiter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doc Ritezel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-07 00:00:00.000000000 Z
11
+ date: 2014-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hashie
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gem-release
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: faker
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: Hoist your code up to Opsworks
@@ -116,11 +116,11 @@ executables:
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
- - .gitignore
120
- - .rspec
121
- - .ruby-gemset
122
- - .ruby-version
123
- - .travis.yml
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".ruby-gemset"
122
+ - ".ruby-version"
123
+ - ".travis.yml"
124
124
  - Gemfile
125
125
  - Guardfile
126
126
  - LICENSE.txt
@@ -158,17 +158,17 @@ require_paths:
158
158
  - lib
159
159
  required_ruby_version: !ruby/object:Gem::Requirement
160
160
  requirements:
161
- - - '>='
161
+ - - ">="
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - '>='
166
+ - - ">="
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.0.14
171
+ rubygems_version: 2.2.0
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Monitor, deploy and maintain your Opsworks application stacks