opsworks-cli 0.4.1 → 0.4.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: bfd9c693a24d5a7f5de807fbc15794a8e4f58c51
4
- data.tar.gz: 9772af5d01fb661eea88f783ef3659ed6b2fe169
3
+ metadata.gz: a6ab71b0b796bf206ce8f8be50e4275267af4651
4
+ data.tar.gz: 898cced859136b9f9fdd39e824180e51f764542e
5
5
  SHA512:
6
- metadata.gz: 95546553bfc0e27b9a3122fc6abe6fde2f1e4118bfbcd4b3144cbbcc7790350b91834ca7c662166ca9a2a81900ec4f2dbc3e7a846fc6ef0f094e872909c5448c
7
- data.tar.gz: aed808326ac06d230b85e2cedcc45bbfaf43637579cceac668d634e81c7fb02b7db44f7564d3a1be5f106698ac16c7952882bf2931ad9a91d4ba28edea21c2c9
6
+ metadata.gz: 2a3b3e7276dacecf8929a4bfd2fd25dc557e8c6dd29ce2e04629dd7aefcc1cac51a679d4b865be05ce2d5c49bdac7e45ee599de6a808d5b69ee66af1dc309f2a
7
+ data.tar.gz: 81dd251f0a67ecf4643151cc30743e2f374d426a98917c4966ac095312a49cc31351df0651ea15854f062752cc6623bd4626e8fdaf704ad7e2642d9637710ae2
@@ -6,7 +6,7 @@ module OpsWorks
6
6
  module Options
7
7
  def parse_stacks(options = {})
8
8
  if options[:stack]
9
- OpsWorks::Stack.all.select! do |stack|
9
+ OpsWorks::Stack.all.select do |stack|
10
10
  options[:stack].include?(stack.name)
11
11
  end
12
12
  else
@@ -12,13 +12,14 @@ module OpsWorks
12
12
  desc 'apps:deploy APP [--stack STACK]', 'Deploy an OpsWorks app'
13
13
  option :stack, type: :array
14
14
  option :timeout, type: :numeric, default: 300
15
+ option :migrate, type: :boolean, default: false
15
16
  define_method 'apps:deploy' do |name|
16
17
  fetch_credentials unless env_credentials?
17
18
  stacks = parse_stacks(options.merge(active: true))
18
19
  deployments = stacks.map do |stack|
19
20
  next unless (app = stack.find_app_by_name(name))
20
21
  say "Deploying to #{stack.name}..."
21
- stack.deploy_app(app)
22
+ stack.deploy_app(app, 'migrate' => [options[:migrate].to_s])
22
23
  end
23
24
  deployments.compact!
24
25
  OpsWorks::Deployment.wait(deployments, options[:timeout])
@@ -1,5 +1,5 @@
1
1
  module OpsWorks
2
2
  module CLI
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  end
5
5
  end
@@ -99,9 +99,15 @@ module OpsWorks
99
99
  )
100
100
  end
101
101
 
102
- def deploy_app(app)
102
+ def deploy_app(app, args = {})
103
103
  fail 'App not found' unless app && app.id
104
- create_deployment(app_id: app.id, command: { name: 'deploy' })
104
+ create_deployment(
105
+ app_id: app.id,
106
+ command: {
107
+ name: 'deploy',
108
+ args: args
109
+ }
110
+ )
105
111
  end
106
112
 
107
113
  def active?
@@ -20,34 +20,50 @@ describe OpsWorks::CLI::Agent do
20
20
  end
21
21
 
22
22
  it 'should update custom cookbooks on all stacks' do
23
- expect(stacks[0]).to receive(:deploy_app).with(app) { success }
24
- expect(stacks[1]).to receive(:deploy_app).with(app) { success }
23
+ expect(stacks[0]).to receive(:deploy_app)
24
+ .with(app, anything) { success }
25
+ expect(stacks[1]).to receive(:deploy_app)
26
+ .with(app, anything) { success }
25
27
  subject.send('apps:deploy', app_name)
26
28
  end
27
29
 
28
30
  it 'should not fail if some stacks are inactive' do
29
31
  allow(OpsWorks::Stack).to receive(:active) { [stacks[0]] }
30
- expect(stacks[0]).to receive(:deploy_app).with(app) { success }
32
+ expect(stacks[0]).to receive(:deploy_app)
33
+ .with(app, anything) { success }
31
34
  expect(stacks[1]).not_to receive(:deploy_app)
32
35
  subject.send('apps:deploy', app_name)
33
36
  end
34
37
 
35
38
  it 'should optionally run on a subset of stacks' do
36
- expect(stacks[0]).to receive(:deploy_app).with(app) { success }
39
+ expect(stacks[0]).to receive(:deploy_app)
40
+ .with(app, anything) { success }
37
41
  expect(stacks[1]).not_to receive(:deploy_app)
38
42
 
39
43
  allow(subject).to receive(:options) { { stack: [stacks[0].name] } }
40
44
  subject.send('apps:deploy', app_name)
41
45
  end
42
46
 
47
+ it 'should optionally run migrations' do
48
+ expect(stacks[0]).to receive(:deploy_app)
49
+ .with(app, 'migrate' => ['true']) { success }
50
+ expect(stacks[1]).to receive(:deploy_app)
51
+ .with(app, 'migrate' => ['true']) { success }
52
+
53
+ allow(subject).to receive(:options) { { migrate: true } }
54
+ subject.send('apps:deploy', app_name)
55
+ end
56
+
43
57
  it 'should not fail if a stack does not have the app' do
44
58
  allow(stacks[0]).to receive(:apps) { [] }
45
- expect(stacks[1]).to receive(:deploy_app).with(app) { success }
59
+ expect(stacks[1]).to receive(:deploy_app)
60
+ .with(app, anything) { success }
46
61
  expect { subject.send('apps:deploy', app_name) }.not_to raise_error
47
62
  end
48
63
 
49
64
  it 'should fail if any update fails' do
50
- expect(stacks[0]).to receive(:deploy_app).with(app) { failure }
65
+ expect(stacks[0]).to receive(:deploy_app)
66
+ .with(app, anything) { failure }
51
67
 
52
68
  allow(subject).to receive(:options) { { stack: [stacks[0].name] } }
53
69
  expect { subject.send('apps:deploy', app_name) }.to raise_error
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opsworks-cli
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
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-19 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor