opsicle 0.8.1 → 0.8.2

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: ea1dcaf04bbc1b390d6d7c9f491b909e10883c3a
4
- data.tar.gz: 547e55829683626e7598ef2324d59dc2f8218cd3
3
+ metadata.gz: b201eac6aa239dec9378f67aa1c34a03898eac11
4
+ data.tar.gz: be6e9ece12c51bd6d7c47b8bed9bac8fc8510ca2
5
5
  SHA512:
6
- metadata.gz: 88e54592591ceffc65377b8e43c249a35119b7df2dfa6789839961d15900f355ecb6d355b2c8891c5e2a98a9a11b5824c2c7a86dcee8d3f70f8def9c222a9d48
7
- data.tar.gz: 7bb7ef31c3860c90b20fd8eb7b1efca8f7e447e8ddc74c1e594c380cc95b21aba2b8d859c539764439b37224a334c62ca116a93b2fa54a85fc3b175756df5da9
6
+ metadata.gz: 6d1136716ed8666abb86979193ae285c5fd3d50534ca111a960d2f8ba1cb2334f96f46f5b23ee51c8c378dfdb2f9156a297f38347ed58006cda4e78a0e884ebe
7
+ data.tar.gz: 2ca94d4ba02f75230c06b1e1e15f549c106f6f26e6ddb60e613d23b13a42de10a4e063e8ee0eee42071c84d4e6a56d74a1d6d1cefbf869ae6b293f9d7521e755
data/bin/opsicle CHANGED
@@ -31,6 +31,7 @@ end
31
31
  on_error do |exception|
32
32
  case exception
33
33
  when Opsicle::Monitor::QuitMonitor
34
+ Opsicle::Output.say exception.message, :success
34
35
  exit 0
35
36
  when Opsicle::Errors::DeployFailed
36
37
  Opsicle::Output.say exception.message, :error
@@ -28,8 +28,9 @@ module Opsicle
28
28
  end
29
29
 
30
30
  def instances
31
- client.api_call(:describe_instances, { stack_id: client.config.opsworks_config[:stack_id] })
32
- .data[:instances]
31
+ @instances ||= client.api_call(:describe_instances, { stack_id: client.config.opsworks_config[:stack_id] })
32
+ .data[:instances]
33
+ .select { |instance| instance[:status].to_s == 'online'}
33
34
  end
34
35
 
35
36
  def ssh_username
@@ -62,13 +62,15 @@ module Opsicle
62
62
  end
63
63
  end
64
64
 
65
- def stop(error=nil)
65
+ def stop(options={})
66
+ options = { error: nil, message: "" }.merge(options)
67
+
66
68
  @running = false
67
69
  wakey_wakey
68
70
  @screen.close
69
71
  @screen = nil # Ruby curses lib doesn't have closed?(), so we set to nil, just in case
70
72
 
71
- raise (error || QuitMonitor)
73
+ options[:error] ? raise(options[:error]) : raise(QuitMonitor, options[:message])
72
74
  end
73
75
 
74
76
  def restart
@@ -167,7 +169,13 @@ module Opsicle
167
169
 
168
170
  def check_deploy_status
169
171
  unless deploy.running?
170
- deploy.failed? ? stop(Opsicle::Errors::DeployFailed.new(deploy.command)) : stop
172
+ if deploy.failed?
173
+ stop(error: Opsicle::Errors::DeployFailed.new(deploy.command))
174
+ elsif deploy.successful?
175
+ stop(message: "Deploy completed successfully")
176
+ else
177
+ stop
178
+ end
171
179
  end
172
180
  end
173
181
 
@@ -1,3 +1,3 @@
1
1
  module Opsicle
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
@@ -81,8 +81,8 @@ module Opsicle
81
81
  it "makes a describe_instances API call" do
82
82
  expect(client).to receive(:api_call).with(:describe_instances, {stack_id: "1234"})
83
83
  .and_return(api_call)
84
- expect(api_call).to receive(:data).and_return(instances: {:foo => :bar})
85
- expect(subject.instances).to eq({:foo => :bar})
84
+ expect(api_call).to receive(:data).and_return(instances: [{:name => :foo, :status => "online"},{:name => :bar, :status => "stopped"}])
85
+ expect(subject.instances).to eq([{:name => :foo, :status=>"online"}])
86
86
  end
87
87
  end
88
88
 
@@ -70,15 +70,21 @@ describe Opsicle::Monitor::App do
70
70
  end
71
71
 
72
72
  context "when called normally" do
73
- it "raises QuitMonitor and exits safely" do
74
- expect { @app.stop }.to raise_error(Opsicle::Monitor::QuitMonitor)
73
+ it "raises QuitMonitor and exits safely without a message" do
74
+ expect { @app.stop }.to raise_error(Opsicle::Monitor::QuitMonitor, "")
75
+ end
76
+ end
77
+
78
+ context "when a message is passed in" do
79
+ it "raises QuitMonitor and exists with message" do
80
+ expect { @app.stop(message: "Hey!") }.to raise_error(Opsicle::Monitor::QuitMonitor, "Hey!")
75
81
  end
76
82
  end
77
83
 
78
84
  context "when a custom error is passed in" do
79
85
  it "raises the custom error" do
80
86
  MyAwesomeCustomError = Class.new(StandardError)
81
- expect { @app.stop(MyAwesomeCustomError) }.to raise_error(MyAwesomeCustomError)
87
+ expect { @app.stop(error: MyAwesomeCustomError) }.to raise_error(MyAwesomeCustomError)
82
88
  end
83
89
  end
84
90
  end
@@ -125,7 +131,7 @@ describe Opsicle::Monitor::App do
125
131
  let(:deployment) { double("deployment", :[] => 'successful') }
126
132
 
127
133
  it "stops the monitor normally" do
128
- expect(@app).to receive(:stop).with(no_args)
134
+ expect(@app).to receive(:stop).with(message: "Deploy completed successfully")
129
135
  @app.send :check_deploy_status
130
136
  end
131
137
  end
@@ -134,7 +140,7 @@ describe Opsicle::Monitor::App do
134
140
  let(:deployment) { double("deployment", :[] => 'failed') }
135
141
 
136
142
  it "stops the monitor with an DeployFailed error" do
137
- expect(@app).to receive(:stop).with(Opsicle::Errors::DeployFailed)
143
+ expect(@app).to receive(:stop).with(error: Opsicle::Errors::DeployFailed)
138
144
  @app.send :check_deploy_status
139
145
  end
140
146
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opsicle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Fleener
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-25 00:00:00.000000000 Z
12
+ date: 2014-12-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  version: '0'
249
249
  requirements: []
250
250
  rubyforge_project:
251
- rubygems_version: 2.4.2
251
+ rubygems_version: 2.2.2
252
252
  signing_key:
253
253
  specification_version: 4
254
254
  summary: An opsworks specific abstraction on top of the aws sdk
@@ -272,3 +272,4 @@ test_files:
272
272
  - spec/opsicle/monitor/subpanel_spec.rb
273
273
  - spec/opsicle/s3_bucket_spec.rb
274
274
  - spec/spec_helper.rb
275
+ has_rdoc: