centurion 1.8.3 → 1.8.4

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: 03c6b6730357fe18ad3c5ba0da07c985f2beb83d
4
- data.tar.gz: ca13d8ee3ae197a28f74332ecba32215afc3234e
3
+ metadata.gz: 369271bc0ce536e622fa0f0af79033e644fabd73
4
+ data.tar.gz: 0a6212a1a65e3c2d5d24dfdc5aee9d41c4144993
5
5
  SHA512:
6
- metadata.gz: 7ef770e7477c372180ea27ce21b1ef76f37745da94513d76ca9a34ab43efa0ad8cd35cf544f82758c636d3c25fd8bbbf9ed8400ac1e78f49730842e3c9b0f964
7
- data.tar.gz: 2d73c5575ad77bc907c58a798e19d42f85e42731d67bd1ef36a9a13d9d45261045432600f8385e1cfad78c2e43724c43815a2b26ba4e897f03e8c8a7da92a03a
6
+ metadata.gz: 1b48a1ff8e0da6f5a2b942ba7a5dbbbd377200c2c0f45c7d763fc99cfa2936a1c3c135f5b6bff84feabe10f813e8e7d18f3e23c1e50b674e96733ea7c1f3aa66
7
+ data.tar.gz: 80a0fdae74711b67cd80cb732a0bf14bfefb56c69bafa0302b07a8b6449dc96873b2552cfc11fbf6a7db4590d0e272fe894ae6eefdffd5f7ccd694b3b697981b
@@ -7,8 +7,11 @@ module Centurion::Deploy
7
7
  FAILED_CONTAINER_VALIDATION = 100
8
8
 
9
9
  def stop_containers(target_server, service, timeout = 30)
10
- old_containers = target_server.find_containers_by_name(service.name) ||
11
- target_server.find_containers_by_public_port(service.public_ports.first)
10
+ old_containers = if service.public_ports.nil? || service.public_ports.empty?
11
+ target_server.find_containers_by_name(service.name)
12
+ else
13
+ target_server.find_containers_by_public_port(service.public_ports.first)
14
+ end
12
15
 
13
16
  info "Stopping container(s): #{old_containers.inspect}"
14
17
 
@@ -75,9 +75,12 @@ module Centurion::DeployDSL
75
75
  end
76
76
 
77
77
  def public_port_for(port_bindings)
78
- # {'80/tcp'=>[{'HostIp'=>'0.0.0.0', 'HostPort'=>'80'}]}
79
- first_port_binding = port_bindings.values.first
80
- first_port_binding.first['HostPort']
78
+ # port_bindings = [#<struct Centurion::Service::PortBinding
79
+ # host_port=17090,
80
+ # container_port=80,
81
+ # type="tcp",
82
+ # host_ip=nil>]
83
+ port_bindings.first.host_port
81
84
  end
82
85
 
83
86
  def host_volume(volume, options)
@@ -16,7 +16,7 @@ class Centurion::DockerServer
16
16
  def_delegators :docker_via_api, :create_container, :inspect_container,
17
17
  :inspect_image, :ps, :start_container, :stop_container,
18
18
  :remove_container, :restart_container
19
- def_delegators :docker_via_cli, :pull, :tail, :attach
19
+ def_delegators :docker_via_cli, :pull, :tail, :attach, :exec
20
20
 
21
21
  def initialize(host, docker_path, tls_params = {})
22
22
  @docker_path = docker_path
@@ -27,6 +27,10 @@ class Centurion::DockerViaCli
27
27
  Centurion::Shell.echo(build_command(:attach, container_id))
28
28
  end
29
29
 
30
+ def exec(container_id, commandline)
31
+ Centurion::Shell.echo(build_command(:exec, "#{container_id} #{commandline}"))
32
+ end
33
+
30
34
  private
31
35
 
32
36
  def self.tls_keys
@@ -61,6 +65,7 @@ class Centurion::DockerViaCli
61
65
  when :pull then ' pull '
62
66
  when :logs then ' logs -f '
63
67
  when :attach then ' attach '
68
+ when :exec then ' exec '
64
69
  end
65
70
  command << destination
66
71
  command
@@ -1,3 +1,3 @@
1
1
  module Centurion
2
- VERSION = '1.8.3'
2
+ VERSION = '1.8.4'
3
3
  end
data/spec/deploy_spec.rb CHANGED
@@ -120,11 +120,25 @@ describe Centurion::Deploy do
120
120
  end
121
121
 
122
122
  describe '#stop_containers' do
123
- it 'calls stop_container on the right containers' do
123
+ it 'calls stop_container on the right containers when ports are mapped' do
124
124
  service = Centurion::Service.new(:centurion)
125
125
  service.add_port_bindings(80, 80)
126
126
 
127
+ second_container = container.dup.tap { |c| c['Id'] = c['Id'].sub(/49494/, '55555') }
128
+ containers = [ container, second_container ]
129
+
130
+ expect(server).to receive(:find_containers_by_public_port).with(80).and_return(containers)
131
+ expect(server).to receive(:stop_container).with(container['Id'], 30).once
132
+ expect(server).to receive(:stop_container).with(second_container['Id'], 30).once
133
+
134
+ test_deploy.stop_containers(server, service)
135
+ end
136
+
137
+ it 'calls stop_container on the right containers when ports are not mapped' do
138
+ service = Centurion::Service.new(:centurion)
139
+
127
140
  second_container = container.dup
141
+ second_container = container.dup.tap { |c| c['Id'] = c['Id'].sub(/49494/, '55555') }
128
142
  containers = [ container, second_container ]
129
143
 
130
144
  expect(server).to receive(:find_containers_by_name).with(:centurion).and_return(containers)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: centurion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nic Benders
@@ -20,7 +20,7 @@ authors:
20
20
  autorequire:
21
21
  bindir: bin
22
22
  cert_chain: []
23
- date: 2015-11-04 00:00:00.000000000 Z
23
+ date: 2015-12-02 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: trollop