dumbwaiter 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/dumbwaiter/app.rb +54 -0
- data/lib/dumbwaiter/cli.rb +18 -68
- data/lib/dumbwaiter/deployment.rb +43 -0
- data/lib/dumbwaiter/stack.rb +39 -0
- data/lib/dumbwaiter/version.rb +1 -1
- data/spec/lib/dumbwaiter/app_spec.rb +71 -0
- data/spec/lib/dumbwaiter/cli_spec.rb +57 -41
- data/spec/lib/dumbwaiter/deployment_spec.rb +45 -0
- data/spec/lib/dumbwaiter/stack_spec.rb +45 -0
- metadata +10 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b69c9d7f2e7d25bd322771b407638c70b5dccef
|
4
|
+
data.tar.gz: 3a5d98c4fe4ddd7e8e3f59b8be15a8e8b94c948f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf1781076eba107b32d03a11e278e03fb429c413ff639999f818ed99d2bee98c51d84f11871d12fd6bee13e403d3b45b50d95f53cd088e8a31ab4a8f1a4289de
|
7
|
+
data.tar.gz: 4cf716ba54f720ac5670c4eec82cdcbbd97a3cba26d8db3eacb208be52a9a45477cad4a3f54970f8895a7e69c70f514f715bd599c2346e6450eb61e4fa2acfca
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Dumbwaiter
|
1
|
+
Dumbwaiter [![Build Status](https://travis-ci.org/minifast/dumbwaiter.png)](https://travis-ci.org/minifast/dumbwaiter) [![Code Climate](https://codeclimate.com/github/minifast/dumbwaiter.png)](https://codeclimate.com/github/minifast/dumbwaiter)
|
2
2
|
==========
|
3
3
|
|
4
4
|
Dumbwaiter hoists your Rails application up to OpsWorks and ratchets deployment
|
@@ -28,9 +28,9 @@ Deploy the "cinnamon" branch of the "syrup" application to the "Pancake" stack:
|
|
28
28
|
|
29
29
|
`dumbwaiter deploy Pancake syrup cinnamon`
|
30
30
|
|
31
|
-
Roll back the "Snowman" stack:
|
31
|
+
Roll back the "Snowman" stack's "dandruff" application:
|
32
32
|
|
33
|
-
`dumbwaiter rollback Snowman`
|
33
|
+
`dumbwaiter rollback Snowman dandruff`
|
34
34
|
|
35
35
|
List the deployments on the "Maniacal Checklist" stack:
|
36
36
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "dumbwaiter/deployment_custom_json"
|
2
|
+
|
3
|
+
class Dumbwaiter::App
|
4
|
+
class NotFound < Exception; end
|
5
|
+
|
6
|
+
attr_reader :stack, :opsworks_app, :opsworks
|
7
|
+
|
8
|
+
def self.all(stack, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
|
9
|
+
opsworks.describe_apps(stack_id: stack.id).apps.map { |app| new(stack, app, opsworks) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.find(stack, app_name, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
|
13
|
+
app = all(stack, opsworks).detect { |app| app.name == app_name}
|
14
|
+
raise NotFound.new("No app found with name #{app_name}") if app.nil?
|
15
|
+
app
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(stack, opsworks_app, opsworks)
|
19
|
+
@stack = stack
|
20
|
+
@opsworks_app = opsworks_app
|
21
|
+
@opsworks = opsworks
|
22
|
+
end
|
23
|
+
|
24
|
+
def name
|
25
|
+
opsworks_app.name
|
26
|
+
end
|
27
|
+
|
28
|
+
def id
|
29
|
+
opsworks_app.app_id
|
30
|
+
end
|
31
|
+
|
32
|
+
def deploy(revision = nil)
|
33
|
+
deployment = as_deployment("deploy", args: {migrate: ["true"]})
|
34
|
+
unless revision.nil?
|
35
|
+
custom_json = Dumbwaiter::DeploymentCustomJson.create(name, revision)
|
36
|
+
deployment[:custom_json] = custom_json.to_json
|
37
|
+
end
|
38
|
+
opsworks.create_deployment(deployment)
|
39
|
+
end
|
40
|
+
|
41
|
+
def rollback
|
42
|
+
opsworks.create_deployment(as_deployment("rollback"))
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def as_deployment(command_name, args = {})
|
48
|
+
{
|
49
|
+
app_id: id,
|
50
|
+
stack_id: stack.id,
|
51
|
+
command: {name: command_name}.merge(args),
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
data/lib/dumbwaiter/cli.rb
CHANGED
@@ -1,91 +1,41 @@
|
|
1
1
|
require "thor"
|
2
2
|
require "aws-sdk-core"
|
3
3
|
require "dumbwaiter/deployment_custom_json"
|
4
|
+
require "dumbwaiter/stack"
|
4
5
|
|
5
6
|
module Dumbwaiter
|
6
7
|
class Cli < Thor
|
7
|
-
class MissingStack < Error; end
|
8
|
-
class MissingApp < Error; end
|
9
|
-
|
10
8
|
desc "deploy STACK_NAME APP_NAME GIT_REF", "Deploy an application revision"
|
11
9
|
def deploy(stack_name, app_name, revision)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
command: {name: "deploy", args: {migrate: ["true"]}},
|
18
|
-
custom_json: custom_json
|
19
|
-
)
|
10
|
+
stack = Stack.find(stack_name)
|
11
|
+
app = App.find(stack, app_name)
|
12
|
+
app.deploy(revision)
|
13
|
+
rescue Dumbwaiter::Stack::NotFound, Dumbwaiter::App::NotFound => e
|
14
|
+
raise Thor::Error.new(e.message)
|
20
15
|
end
|
21
16
|
|
22
17
|
desc "rollback STACK_NAME APP_NAME", "Roll back an application"
|
23
18
|
def rollback(stack_name, app_name)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
)
|
19
|
+
stack = Stack.find(stack_name)
|
20
|
+
app = App.find(stack, app_name)
|
21
|
+
app.rollback
|
22
|
+
rescue Dumbwaiter::Stack::NotFound, Dumbwaiter::App::NotFound => e
|
23
|
+
raise Thor::Error.new(e.message)
|
30
24
|
end
|
31
25
|
|
32
26
|
desc "list STACK_NAME", "List all the deployments for a stack"
|
33
27
|
def list(stack_name)
|
34
|
-
|
35
|
-
app_deployments = deployments(stack_id).select do |deployment|
|
36
|
-
%w(rollback deploy).include?(deployment.command.name)
|
37
|
-
end
|
38
|
-
|
39
|
-
app_deployments.each do |deployment|
|
40
|
-
custom_json = DeploymentCustomJson.from_json(deployment.custom_json || "{}")
|
41
|
-
Kernel.puts "#{deployment.created_at} - #{deployment.command.name} - #{deployment.status} - #{custom_json.git_ref}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
no_tasks do
|
46
|
-
def app_id_for_name(stack_id, app_name)
|
47
|
-
app_id = app_ids_by_name(stack_id)[app_name]
|
48
|
-
raise MissingApp.new("No app named #{app_name}") unless app_id
|
49
|
-
app_id
|
50
|
-
end
|
51
|
-
|
52
|
-
def stack_id_for_name(stack_name)
|
53
|
-
stack_id = stack_ids_by_name[stack_name]
|
54
|
-
raise MissingStack.new("No stack named #{stack_name}") unless stack_id
|
55
|
-
stack_id
|
56
|
-
end
|
57
|
-
|
58
|
-
def stack_ids_by_name
|
59
|
-
@stack_ids_by_name ||= stacks.reduce({}) do |result, stack|
|
60
|
-
result[stack.name] = stack.stack_id
|
61
|
-
result
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def app_ids_by_name(stack_id)
|
66
|
-
apps(stack_id).reduce({}) do |result, app|
|
67
|
-
result[app.name] = app.app_id
|
68
|
-
result
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def stacks
|
73
|
-
@stacks ||= opsworks.describe_stacks.stacks
|
74
|
-
end
|
75
|
-
|
76
|
-
def apps(stack_id)
|
77
|
-
@apps ||= {}
|
78
|
-
@apps[stack_id] ||= opsworks.describe_apps(stack_id: stack_id).apps
|
79
|
-
end
|
28
|
+
stack = Stack.find(stack_name)
|
80
29
|
|
81
|
-
|
82
|
-
|
83
|
-
@deployments[stack_id] ||= opsworks.describe_deployments(stack_id: stack_id).deployments
|
30
|
+
deployments = stack.deployments.select do |deployment|
|
31
|
+
%w(rollback deploy).include?(deployment.command_name)
|
84
32
|
end
|
85
33
|
|
86
|
-
|
87
|
-
|
34
|
+
deployments.each do |deployment|
|
35
|
+
Kernel.puts(deployment.to_log)
|
88
36
|
end
|
37
|
+
rescue Dumbwaiter::Stack::NotFound => e
|
38
|
+
raise Thor::Error.new(e.message)
|
89
39
|
end
|
90
40
|
end
|
91
41
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "dumbwaiter/deployment_custom_json"
|
2
|
+
|
3
|
+
class Dumbwaiter::Deployment
|
4
|
+
attr_reader :opsworks_deployment
|
5
|
+
|
6
|
+
def self.all(stack_id, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
|
7
|
+
opsworks.describe_deployments(stack_id: stack_id).deployments.map { |d| new(d) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(opsworks_deployment)
|
11
|
+
@opsworks_deployment = opsworks_deployment
|
12
|
+
end
|
13
|
+
|
14
|
+
def created_at
|
15
|
+
opsworks_deployment.created_at
|
16
|
+
end
|
17
|
+
|
18
|
+
def command_name
|
19
|
+
opsworks_deployment.command.name
|
20
|
+
end
|
21
|
+
|
22
|
+
def status
|
23
|
+
opsworks_deployment.status
|
24
|
+
end
|
25
|
+
|
26
|
+
def git_ref
|
27
|
+
deployment_custom_json.git_ref
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_log
|
31
|
+
"#{created_at} - #{command_name} - #{status} - #{git_ref}"
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def deployment_custom_json
|
37
|
+
Dumbwaiter::DeploymentCustomJson.from_json(custom_json)
|
38
|
+
end
|
39
|
+
|
40
|
+
def custom_json
|
41
|
+
opsworks_deployment.custom_json || "{}"
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "dumbwaiter/app"
|
2
|
+
require "dumbwaiter/deployment"
|
3
|
+
|
4
|
+
class Dumbwaiter::Stack
|
5
|
+
attr_reader :opsworks, :opsworks_stack
|
6
|
+
|
7
|
+
class NotFound < Exception; end
|
8
|
+
|
9
|
+
def self.all(opsworks = Aws::OpsWorks.new(region: "us-east-1"))
|
10
|
+
opsworks.describe_stacks.stacks.map { |stack| new(stack, opsworks) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.find(stack_name, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
|
14
|
+
stack = all(opsworks).detect { |stack| stack.name == stack_name}
|
15
|
+
raise NotFound.new("No stack found with name #{stack_name}") if stack.nil?
|
16
|
+
stack
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(opsworks_stack, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
|
20
|
+
@opsworks = opsworks
|
21
|
+
@opsworks_stack = opsworks_stack
|
22
|
+
end
|
23
|
+
|
24
|
+
def name
|
25
|
+
opsworks_stack.name
|
26
|
+
end
|
27
|
+
|
28
|
+
def id
|
29
|
+
opsworks_stack.stack_id
|
30
|
+
end
|
31
|
+
|
32
|
+
def apps
|
33
|
+
@apps ||= Dumbwaiter::App.all(id, opsworks)
|
34
|
+
end
|
35
|
+
|
36
|
+
def deployments
|
37
|
+
@deployments ||= Dumbwaiter::Deployment.all(id, opsworks)
|
38
|
+
end
|
39
|
+
end
|
data/lib/dumbwaiter/version.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Dumbwaiter::App do
|
4
|
+
let(:fake_stack) { double(:stack, id: "pancakes") }
|
5
|
+
let(:fake_app) { double(:app, name: "goose", app_id: "amazing") }
|
6
|
+
let(:fake_apps) { double(:apps, apps: [fake_app]) }
|
7
|
+
let(:fake_opsworks) { double(:opsworks, describe_apps: fake_apps) }
|
8
|
+
|
9
|
+
subject(:app) { Dumbwaiter::App.new(fake_stack, fake_app, fake_opsworks) }
|
10
|
+
|
11
|
+
its(:stack) { should == fake_stack }
|
12
|
+
its(:opsworks_app) { should == fake_app }
|
13
|
+
its(:id) { should == "amazing" }
|
14
|
+
its(:name) { should == "goose" }
|
15
|
+
|
16
|
+
describe "#deploy" do
|
17
|
+
context "when no revision is specified" do
|
18
|
+
it "creates a deployment" do
|
19
|
+
fake_opsworks.should_receive(:create_deployment) do |params|
|
20
|
+
params[:stack_id].should == "pancakes"
|
21
|
+
params[:app_id].should == "amazing"
|
22
|
+
params[:command].should == {name: "deploy", args: {migrate: ["true"]}}
|
23
|
+
end
|
24
|
+
app.deploy
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when a revision is specified" do
|
29
|
+
it "creates a deployment with a revision" do
|
30
|
+
fake_opsworks.should_receive(:create_deployment) do |params|
|
31
|
+
params[:custom_json].should == {deploy: {"goose" => {scm: {revision: "golden"}}}}.to_json
|
32
|
+
end
|
33
|
+
app.deploy("golden")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#rollback" do
|
39
|
+
it "creates a rollback" do
|
40
|
+
fake_opsworks.should_receive(:create_deployment) do |params|
|
41
|
+
params[:stack_id].should == "pancakes"
|
42
|
+
params[:app_id].should == "amazing"
|
43
|
+
params[:command].should == {name: "rollback"}
|
44
|
+
end
|
45
|
+
app.rollback
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".all" do
|
50
|
+
it "fetches all the apps" do
|
51
|
+
fake_opsworks.should_receive(:describe_apps).with(stack_id: "pancakes")
|
52
|
+
Dumbwaiter::App.all(fake_stack, fake_opsworks).should have(1).app
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe ".find" do
|
57
|
+
context "when the app exists" do
|
58
|
+
it "finds the app by name" do
|
59
|
+
Dumbwaiter::App.find(fake_stack, "goose", fake_opsworks).id.should == "amazing"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when the app does not exist" do
|
64
|
+
it "blows up" do
|
65
|
+
expect {
|
66
|
+
Dumbwaiter::App.find(fake_stack, "teeth", fake_opsworks)
|
67
|
+
}.to raise_error(Dumbwaiter::App::NotFound)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -1,85 +1,101 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Dumbwaiter::Cli do
|
4
|
-
let(:fake_stack) { double(:stack, name: "ducks",
|
5
|
-
let(:
|
6
|
-
|
7
|
-
let(:fake_app) { double(:app, name: "reifel", app_id: "wat") }
|
8
|
-
let(:fake_apps) { double(:apps, apps: [fake_app]) }
|
9
|
-
|
10
|
-
let(:custom_json) { {deploy: {"reifel" => {scm: {revision: "corn"}}}} }
|
4
|
+
let(:fake_stack) { double(:stack, name: "ducks", id: "wat") }
|
5
|
+
let(:fake_app) { double(:app, name: "reifel") }
|
11
6
|
|
12
7
|
subject(:cli) { Dumbwaiter::Cli.new }
|
13
8
|
|
14
|
-
before
|
9
|
+
before do
|
10
|
+
Dumbwaiter::Stack.stub(all: [fake_stack])
|
11
|
+
Dumbwaiter::App.stub(all: [fake_app])
|
12
|
+
end
|
15
13
|
|
16
14
|
describe "#deploy" do
|
17
15
|
context "when the stack exists" do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
context "when the app exists" do
|
17
|
+
it "deploys the stack with the resolved id" do
|
18
|
+
fake_app.should_receive(:deploy).with("corn")
|
19
|
+
cli.deploy("ducks", "reifel", "corn")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when the app does not exist" do
|
24
|
+
it "blows up" do
|
25
|
+
expect { cli.deploy("ducks", "squirrel", "corn") }.to raise_error(Thor::Error)
|
23
26
|
end
|
24
|
-
cli.deploy("ducks", "reifel", "corn")
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
context "when the stack does not exist" do
|
29
|
-
let(:fake_stack) { double(:stack, name: "tacos", stack_id: "great") }
|
30
|
-
|
31
31
|
it "blows up" do
|
32
|
-
expect {
|
33
|
-
cli.deploy("ducks", "reifel", "corn")
|
34
|
-
}.to raise_error(Dumbwaiter::Cli::MissingStack)
|
32
|
+
expect { cli.deploy("toques", "reifel", "corn") }.to raise_error(Thor::Error)
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
39
37
|
describe "#rollback" do
|
40
38
|
context "when the stack exists" do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
context "when the app exists" do
|
40
|
+
it "deploys the stack with the resolved id" do
|
41
|
+
fake_app.should_receive(:rollback)
|
42
|
+
cli.rollback("ducks", "reifel")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when the app does not exist" do
|
47
|
+
it "blows up" do
|
48
|
+
expect { cli.rollback("ducks", "montreal") }.to raise_error(Thor::Error)
|
46
49
|
end
|
47
|
-
cli.rollback("ducks", "reifel")
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
51
53
|
context "when the stack does not exist" do
|
52
|
-
let(:fake_stack) { double(:stack, name: "tacos", stack_id: "great") }
|
53
|
-
|
54
54
|
it "blows up" do
|
55
55
|
expect {
|
56
|
-
cli.rollback("
|
57
|
-
}.to raise_error(
|
56
|
+
cli.rollback("maple syrup", "reifel")
|
57
|
+
}.to raise_error(Thor::Error)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
describe "#list" do
|
63
|
-
|
64
|
-
|
65
|
-
let(:fake_deployments) { double(:deployments, deployments: [fake_deployment]) }
|
63
|
+
context "when the stack exists" do
|
64
|
+
before { fake_stack.stub(deployments: [fake_deployment]) }
|
66
65
|
|
67
|
-
|
66
|
+
context "when the deployment is a rollback" do
|
67
|
+
let(:fake_deployment) { double(:deployment, command_name: "rollback", to_log: "oops!") }
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
it "lists the deployment" do
|
70
|
+
Kernel.should_receive(:puts).with("oops!")
|
71
|
+
cli.list("ducks")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "when the deployment is a deploy" do
|
76
|
+
let(:fake_deployment) { double(:deployment, command_name: "deploy", to_log: "whee!") }
|
77
|
+
|
78
|
+
it "lists the deployment" do
|
79
|
+
Kernel.should_receive(:puts).with("whee!")
|
80
|
+
cli.list("ducks")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when the deployment is something else" do
|
85
|
+
let(:fake_deployment) { double(:deployment, command_name: "gargle", to_log: "brblrgl") }
|
86
|
+
|
87
|
+
it "does not print anything" do
|
88
|
+
Kernel.should_not_receive(:puts)
|
89
|
+
cli.list("ducks")
|
90
|
+
end
|
73
91
|
end
|
74
92
|
end
|
75
93
|
|
76
94
|
context "when the stack does not exist" do
|
77
|
-
let(:fake_stack) { double(:stack, name: "tacos", stack_id: "great") }
|
78
|
-
|
79
95
|
it "blows up" do
|
80
96
|
expect {
|
81
|
-
cli.list("
|
82
|
-
}.to raise_error(
|
97
|
+
cli.list("wat")
|
98
|
+
}.to raise_error(Thor::Error)
|
83
99
|
end
|
84
100
|
end
|
85
101
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Dumbwaiter::Deployment do
|
4
|
+
let(:fake_command) { double(:command, name: "deplode") }
|
5
|
+
let(:custom_json) { JSON.dump(deploy: {"hockey" => {scm: {revision: "eh-buddy"}}}) }
|
6
|
+
let(:fake_deployment) do
|
7
|
+
double(:deployment,
|
8
|
+
created_at: "yo",
|
9
|
+
command: fake_command,
|
10
|
+
status: "badical",
|
11
|
+
custom_json: custom_json
|
12
|
+
)
|
13
|
+
end
|
14
|
+
let(:fake_deployments) { double(:deployments, deployments: [fake_deployment]) }
|
15
|
+
let(:fake_opsworks) { double(:opsworks, describe_deployments: fake_deployments) }
|
16
|
+
|
17
|
+
subject(:deployment) { Dumbwaiter::Deployment.new(fake_deployment) }
|
18
|
+
|
19
|
+
its(:opsworks_deployment) { should == fake_deployment }
|
20
|
+
its(:created_at) { should == "yo" }
|
21
|
+
its(:command_name) { should == "deplode" }
|
22
|
+
its(:status) { should == "badical" }
|
23
|
+
its(:git_ref) { should == "eh-buddy" }
|
24
|
+
its(:to_log) { should == "yo - deplode - badical - eh-buddy" }
|
25
|
+
|
26
|
+
context "when custom_json is nil" do
|
27
|
+
let(:fake_deployment) do
|
28
|
+
double(:deployment,
|
29
|
+
created_at: "yo",
|
30
|
+
command: fake_command,
|
31
|
+
status: "badical",
|
32
|
+
custom_json: nil
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
its(:git_ref) { should == "HEAD" }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe ".all" do
|
40
|
+
it "fetches all the deployments" do
|
41
|
+
fake_opsworks.should_receive(:describe_deployments).with(stack_id: "pancakes")
|
42
|
+
Dumbwaiter::Deployment.all("pancakes", fake_opsworks).should have(1).app
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Dumbwaiter::Stack do
|
4
|
+
let(:fake_stack) { double(:stack, name: "ducks", stack_id: "cool") }
|
5
|
+
let(:fake_stacks) { double(:stacks, stacks: [fake_stack]) }
|
6
|
+
let(:fake_opsworks) { double(:opsworks, describe_stacks: fake_stacks) }
|
7
|
+
let(:fake_app) { double(:app) }
|
8
|
+
let(:fake_deployment) { double(:deployment) }
|
9
|
+
|
10
|
+
subject(:stack) { Dumbwaiter::Stack.new(fake_stack) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
Dumbwaiter::App.stub(all: [fake_app])
|
14
|
+
Dumbwaiter::Deployment.stub(all: [fake_deployment])
|
15
|
+
end
|
16
|
+
|
17
|
+
its(:opsworks_stack) { should == fake_stack }
|
18
|
+
its(:id) { should == "cool" }
|
19
|
+
its(:name) { should == "ducks" }
|
20
|
+
|
21
|
+
its(:apps) { should == [fake_app] }
|
22
|
+
its(:deployments) { should == [fake_deployment] }
|
23
|
+
|
24
|
+
describe ".all" do
|
25
|
+
it "fetches all the stacks" do
|
26
|
+
Dumbwaiter::Stack.all(fake_opsworks).should have(1).stack
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".find" do
|
31
|
+
context "when the stack exists" do
|
32
|
+
it "finds the stack by name" do
|
33
|
+
Dumbwaiter::Stack.find("ducks", fake_opsworks).id.should == "cool"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when the stack does not exist" do
|
38
|
+
it "blows up" do
|
39
|
+
expect {
|
40
|
+
Dumbwaiter::Stack.find("teeth", fake_opsworks)
|
41
|
+
}.to raise_error(Dumbwaiter::Stack::NotFound)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dumbwaiter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doc Ritezel
|
@@ -114,12 +114,18 @@ files:
|
|
114
114
|
- bin/dumbwaiter
|
115
115
|
- dumbwaiter.gemspec
|
116
116
|
- lib/dumbwaiter.rb
|
117
|
+
- lib/dumbwaiter/app.rb
|
117
118
|
- lib/dumbwaiter/cli.rb
|
119
|
+
- lib/dumbwaiter/deployment.rb
|
118
120
|
- lib/dumbwaiter/deployment_custom_json.rb
|
121
|
+
- lib/dumbwaiter/stack.rb
|
119
122
|
- lib/dumbwaiter/version.rb
|
120
123
|
- script/ci.sh
|
124
|
+
- spec/lib/dumbwaiter/app_spec.rb
|
121
125
|
- spec/lib/dumbwaiter/cli_spec.rb
|
122
126
|
- spec/lib/dumbwaiter/deployment_custom_json_spec.rb
|
127
|
+
- spec/lib/dumbwaiter/deployment_spec.rb
|
128
|
+
- spec/lib/dumbwaiter/stack_spec.rb
|
123
129
|
- spec/spec_helper.rb
|
124
130
|
homepage: https://github.com/minifast/dumbwaiter
|
125
131
|
licenses:
|
@@ -146,6 +152,9 @@ signing_key:
|
|
146
152
|
specification_version: 4
|
147
153
|
summary: Monitor, deploy and maintain your Opsworks application stacks
|
148
154
|
test_files:
|
155
|
+
- spec/lib/dumbwaiter/app_spec.rb
|
149
156
|
- spec/lib/dumbwaiter/cli_spec.rb
|
150
157
|
- spec/lib/dumbwaiter/deployment_custom_json_spec.rb
|
158
|
+
- spec/lib/dumbwaiter/deployment_spec.rb
|
159
|
+
- spec/lib/dumbwaiter/stack_spec.rb
|
151
160
|
- spec/spec_helper.rb
|