docker-armada 2.10.0 → 2.11.0

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: 07425522f5d4155dc279065cd10bafbf58810e80
4
- data.tar.gz: f3280a0c6fa4810e80fad1ca8ccc191df15e48da
3
+ metadata.gz: e0bc7638f849276cf9ce0ca28a8809184026e82f
4
+ data.tar.gz: 48d9abd7825dbdc77d2f8744ecc69cb6bfa8895e
5
5
  SHA512:
6
- metadata.gz: 4d473688aa84861851f092f92b94842515bd0d9104061e59ef8c3cd6b8315c75c85e042bba84491955dcb1980427949255c004b80007100bb0ffa5902f0eb118
7
- data.tar.gz: 631387c0304361e2362c2db99ebb8469d91113f462c88c50206ed835a193ce35a2e3dde68ba3684a0aabea3edea4c2ae79faefd1bf85ea7b0345a0f25565d443
6
+ metadata.gz: 682da6b088a024e8016f7d58c313cdb981ca8057ea65d98cf0b1f809e341f36db0a76da420a28d08bc7de793435809b5285ad2a426449a73c865a8098f1b713e
7
+ data.tar.gz: eaf1fee5f6449ee42e359d6bfb45d567286a5c7d113f93e3bdd858b3aa0501bc793ae3ecd09ac65893f6a374e0b763208fd401e6db78fe2285f92930620b4fdc
@@ -10,11 +10,14 @@ module Armada
10
10
  end
11
11
 
12
12
  def run
13
- Armada.ui.info "Deploying the following image [#{@options[:image]}:#{@options[:tag]}] to these host(s) #{@options[:hosts].join(', ')} in PARALLEL"
13
+ Armada.ui.info "Deploying the following image [#{@options[:image]}:#{@options[:tag]}] in PARALLEL"
14
14
 
15
15
  begin
16
16
  @options[:hosts].each_in_parallel do |host|
17
- docker_host = Armada::Host.create(host, options)
17
+ docker_host_connect_string = host[:docker_host] || host
18
+ health_check_host = host[:health_check_host] || host
19
+
20
+ docker_host = Armada::Host.create(docker_host_connect_string, options)
18
21
  image = docker_host.get_image @options[:image], @options[:tag], @options
19
22
  image.pull
20
23
 
@@ -36,7 +39,7 @@ module Armada
36
39
  end
37
40
 
38
41
  health_check = Armada::Connection::HealthCheck.new(
39
- host,
42
+ health_check_host,
40
43
  health_check_port,
41
44
  @options[:health_check_endpoint],
42
45
  @options[:health_check_delay],
@@ -45,7 +48,7 @@ module Armada
45
48
  @options[:ssh_gateway_user]
46
49
  )
47
50
 
48
- raise "Health check failed! - #{host}" unless health_check.run
51
+ raise "Health check failed! - #{health_check_host}" unless health_check.run
49
52
  end
50
53
  end
51
54
  rescue Exception => e
@@ -10,15 +10,18 @@ module Armada
10
10
  end
11
11
 
12
12
  def run
13
- Armada.ui.info "Deploying the following image [#{@options[:image]}:#{@options[:tag]}] to these host(s) #{@options[:hosts].join(', ')}"
13
+ Armada.ui.info "Deploying the following image [#{@options[:image]}:#{@options[:tag]}]"
14
14
  begin
15
15
  @options[:hosts].each_in_parallel do |host|
16
- docker_host = Armada::Host.create(host, options)
16
+ docker_host_connect_string = host[:docker_host] || host
17
+ docker_host = Armada::Host.create(docker_host_connect_string, options)
17
18
  docker_host.get_image(@options[:image], @options[:tag], @options).pull
18
19
  end
19
20
 
20
21
  @options[:hosts].each do |host|
21
- docker_host = Armada::Host.create(host, options)
22
+ docker_host_connect_string = host[:docker_host] || host
23
+ health_check_host = host[:health_check_host] || host
24
+ docker_host = Armada::Host.create(docker_host_connect_string, options)
22
25
  image = docker_host.get_image @options[:image], @options[:tag], @options
23
26
  container = Armada::Container.new(image, docker_host, @options)
24
27
  container.stop
@@ -38,7 +41,7 @@ module Armada
38
41
  end
39
42
 
40
43
  health_check = Armada::Connection::HealthCheck.new(
41
- host,
44
+ health_check_host,
42
45
  health_check_port,
43
46
  @options[:health_check_endpoint],
44
47
  @options[:health_check_delay],
@@ -47,7 +50,7 @@ module Armada
47
50
  @options[:ssh_gateway_user]
48
51
  )
49
52
 
50
- raise "Health check failed! - #{host}" unless health_check.run
53
+ raise "Health check failed! - #{health_check_host}" unless health_check.run
51
54
  end
52
55
  end
53
56
  rescue Exception => e
@@ -81,6 +81,15 @@ module Armada::DeployDSL
81
81
 
82
82
  def host(hostname)
83
83
  current = fetch(:hosts, [])
84
+
85
+ if hostname.is_a? Hash
86
+ if not hostname.has_key? :docker_host or not hostname.has_key? :health_check_host
87
+ raise ArgumentError.new("Host must contain :docker_host and :health_check_host if supplied as a hash")
88
+ end
89
+ elsif not hostname.is_a? String
90
+ raise ArgumentError.new("Host must be a String or a Hash containing the :docker_host and :health_check_host keys")
91
+ end
92
+
84
93
  current << hostname
85
94
  set(:hosts, current)
86
95
  end
@@ -23,6 +23,18 @@ describe Armada::DeployDSL do
23
23
  expect(DeployDSLTest.fetch(:hosts)).to include("host1", "host2")
24
24
  end
25
25
 
26
+ it 'supports adding hosts via hash' do
27
+ DeployDSLTest.set(:hosts, ['my-other-host'])
28
+ DeployDSLTest.host({:docker_host => 'host1', :health_check_host => 'host2'})
29
+ expect(DeployDSLTest.fetch(:hosts)).to include('my-other-host', {:docker_host => 'host1', :health_check_host => 'host2'})
30
+ end
31
+
32
+ it 'should raise an argumenterror if the host argument is incorrect' do
33
+ expect { DeployDSLTest.host({:docker_host => 'host1'}) }.to raise_error(ArgumentError)
34
+ expect { DeployDSLTest.host({:health_check_host => 'host1'}) }.to raise_error(ArgumentError)
35
+ expect { DeployDSLTest.host(1) }.to raise_error(ArgumentError)
36
+ end
37
+
26
38
  it 'adds the restart policy' do
27
39
  DeployDSLTest.restart_policy({:foo => "bar"})
28
40
  expect(DeployDSLTest.fetch(:restart_policy)).to eq({:foo => "bar"})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-armada
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Chauncey