centurion 1.6.0 → 1.8.0
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 +7 -0
- data/CONTRIBUTORS.md +2 -0
- data/README.md +100 -15
- data/lib/centurion/deploy.rb +36 -134
- data/lib/centurion/deploy_dsl.rb +62 -21
- data/lib/centurion/docker_server.rb +12 -2
- data/lib/centurion/docker_via_api.rb +18 -10
- data/lib/centurion/dogestry.rb +16 -2
- data/lib/centurion/service.rb +218 -0
- data/lib/centurion/version.rb +1 -1
- data/lib/core_ext/numeric_bytes.rb +59 -57
- data/lib/tasks/centurion.rake +3 -0
- data/lib/tasks/deploy.rake +29 -42
- data/spec/deploy_dsl_spec.rb +78 -17
- data/spec/deploy_spec.rb +45 -343
- data/spec/docker_server_spec.rb +16 -1
- data/spec/docker_via_api_spec.rb +32 -55
- data/spec/service_spec.rb +288 -0
- metadata +27 -42
data/spec/docker_server_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe Centurion::DockerServer do
|
|
11
11
|
'Created' => 1414797234,
|
12
12
|
'Id' => '28970c706db0f69716af43527ed926acbd82581e1cef5e4e6ff152fce1b79972',
|
13
13
|
'Image' => 'centurion-test:latest',
|
14
|
-
'Names' => ['/centurion-
|
14
|
+
'Names' => ['/centurion-783aac48378283'],
|
15
15
|
'Ports' => [{'PrivatePort'=>80, 'Type'=>'tcp', 'IP'=>'0.0.0.0', 'PublicPort'=>23235}],
|
16
16
|
'Status' => 'Up 3 days'
|
17
17
|
}
|
@@ -74,4 +74,19 @@ describe Centurion::DockerServer do
|
|
74
74
|
expect(server.find_containers_by_name('fbomb')).to be_empty
|
75
75
|
end
|
76
76
|
end
|
77
|
+
|
78
|
+
context 'finding old containers' do
|
79
|
+
it 'finds stopped containers for the given service name' do
|
80
|
+
inspected_containers =
|
81
|
+
[
|
82
|
+
{"Id" => "123", "Names" => ["/centurion-1234567890abcd"], "Status" => "Exit 0"},
|
83
|
+
{"Id" => "456", "Names" => ["/centurion-2234567890abcd"], "Status" => "Running blah blah"},
|
84
|
+
{"Id" => "789", "Names" => ["/centurion-3234567890abcd"], "Status" => "Exited 1 mins ago"},
|
85
|
+
{"Id" => "918", "Names" => ["/fbomb-3234567890abcd"], "Status" => "Exited 1 mins ago"},
|
86
|
+
]
|
87
|
+
allow(server).to receive(:ps).and_return(inspected_containers)
|
88
|
+
|
89
|
+
expect(server.old_containers_for_name('centurion').map { |c| c['Id'] }).to eq(["123", "789"])
|
90
|
+
end
|
91
|
+
end
|
77
92
|
end
|
data/spec/docker_via_api_spec.rb
CHANGED
@@ -6,13 +6,6 @@ describe Centurion::DockerViaApi do
|
|
6
6
|
let(:port) { '2375' }
|
7
7
|
let(:json_string) { '[{ "Hello": "World" }]' }
|
8
8
|
let(:json_value) { JSON.load(json_string) }
|
9
|
-
let(:inspected_containers) do
|
10
|
-
[
|
11
|
-
{"Id" => "123", "Status" => "Exit 0"},
|
12
|
-
{"Id" => "456", "Status" => "Running blah blah"},
|
13
|
-
{"Id" => "789", "Status" => "Exited 1 mins ago"},
|
14
|
-
]
|
15
|
-
end
|
16
9
|
|
17
10
|
context 'without TLS certificates' do
|
18
11
|
let(:excon_uri) { "http://#{hostname}:#{port}/" }
|
@@ -81,6 +74,20 @@ describe Centurion::DockerViaApi do
|
|
81
74
|
api.stop_container('12345')
|
82
75
|
end
|
83
76
|
|
77
|
+
it 'restarts a container' do
|
78
|
+
expect(Excon).to receive(:post).
|
79
|
+
with(excon_uri + "v1.10" + "/containers/12345/restart?t=30", {}).
|
80
|
+
and_return(double(body: json_string, status: 204))
|
81
|
+
api.restart_container('12345')
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'restarts a container with a custom timeout' do
|
85
|
+
expect(Excon).to receive(:post).
|
86
|
+
with(excon_uri + "v1.10" + "/containers/12345/restart?t=300", {}).
|
87
|
+
and_return(double(body: json_string, status: 204))
|
88
|
+
api.restart_container('12345', 300)
|
89
|
+
end
|
90
|
+
|
84
91
|
it 'inspects a container' do
|
85
92
|
expect(Excon).to receive(:get).
|
86
93
|
with(excon_uri + 'v1.7/containers/12345/json', {}).
|
@@ -95,20 +102,6 @@ describe Centurion::DockerViaApi do
|
|
95
102
|
expect(api.remove_container('12345')).to eq(true)
|
96
103
|
end
|
97
104
|
|
98
|
-
it 'lists old containers for a port' do
|
99
|
-
expect(Excon).to receive(:get).
|
100
|
-
with(excon_uri + 'v1.7/containers/json?all=1', {}).
|
101
|
-
and_return(double(body: inspected_containers.to_json, status: 200))
|
102
|
-
expect(Excon).to receive(:get).
|
103
|
-
with(excon_uri + 'v1.7/containers/123/json', {}).
|
104
|
-
and_return(double(body: inspected_container_on_port("123", 8485).to_json, status: 200))
|
105
|
-
expect(Excon).to receive(:get).
|
106
|
-
with(excon_uri + 'v1.7/containers/789/json', {}).
|
107
|
-
and_return(double(body: inspected_container_on_port("789", 8486).to_json, status: 200))
|
108
|
-
|
109
|
-
expect(api.old_containers_for_port(8485)).to eq([{"Id" => "123", "Status" => "Exit 0"}])
|
110
|
-
end
|
111
|
-
|
112
105
|
it 'inspects an image' do
|
113
106
|
expect(Excon).to receive(:get).
|
114
107
|
with(excon_uri + "v1.7" + "/images/foo:bar/json",
|
@@ -198,6 +191,24 @@ describe Centurion::DockerViaApi do
|
|
198
191
|
api.stop_container('12345')
|
199
192
|
end
|
200
193
|
|
194
|
+
it 'restarts a container' do
|
195
|
+
expect(Excon).to receive(:post).
|
196
|
+
with(excon_uri + "v1.10" + "/containers/12345/restart?t=30",
|
197
|
+
client_cert: '/certs/cert.pem',
|
198
|
+
client_key: '/certs/key.pem').
|
199
|
+
and_return(double(body: json_string, status: 204))
|
200
|
+
api.restart_container('12345')
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'restarts a container with a custom timeout' do
|
204
|
+
expect(Excon).to receive(:post).
|
205
|
+
with(excon_uri + "v1.10" + "/containers/12345/restart?t=300",
|
206
|
+
client_cert: '/certs/cert.pem',
|
207
|
+
client_key: '/certs/key.pem').
|
208
|
+
and_return(double(body: json_string, status: 204))
|
209
|
+
api.restart_container('12345', 300)
|
210
|
+
end
|
211
|
+
|
201
212
|
it 'inspects a container' do
|
202
213
|
expect(Excon).to receive(:get).
|
203
214
|
with(excon_uri + 'v1.7/containers/12345/json',
|
@@ -215,26 +226,6 @@ describe Centurion::DockerViaApi do
|
|
215
226
|
and_return(double(status: 204))
|
216
227
|
expect(api.remove_container('12345')).to eq(true)
|
217
228
|
end
|
218
|
-
|
219
|
-
it 'lists old containers for a port' do
|
220
|
-
expect(Excon).to receive(:get).
|
221
|
-
with(excon_uri + 'v1.7/containers/json?all=1',
|
222
|
-
client_cert: '/certs/cert.pem',
|
223
|
-
client_key: '/certs/key.pem').
|
224
|
-
and_return(double(body: inspected_containers.to_json, status: 200))
|
225
|
-
expect(Excon).to receive(:get).
|
226
|
-
with(excon_uri + 'v1.7/containers/123/json',
|
227
|
-
client_cert: '/certs/cert.pem',
|
228
|
-
client_key: '/certs/key.pem').
|
229
|
-
and_return(double(body: inspected_container_on_port("123", 8485).to_json, status: 200))
|
230
|
-
expect(Excon).to receive(:get).
|
231
|
-
with(excon_uri + 'v1.7/containers/789/json',
|
232
|
-
client_cert: '/certs/cert.pem',
|
233
|
-
client_key: '/certs/key.pem').
|
234
|
-
and_return(double(body: inspected_container_on_port("789", 8486).to_json, status: 200))
|
235
|
-
|
236
|
-
expect(api.old_containers_for_port(8485)).to eq([{"Id" => "123", "Status" => "Exit 0"}])
|
237
|
-
end
|
238
229
|
end
|
239
230
|
|
240
231
|
context 'with default TLS certificates' do
|
@@ -251,18 +242,4 @@ describe Centurion::DockerViaApi do
|
|
251
242
|
expect(api.ps).to eq(json_value)
|
252
243
|
end
|
253
244
|
end
|
254
|
-
|
255
|
-
def inspected_container_on_port(id, port)
|
256
|
-
{
|
257
|
-
"Id" => id.to_s,
|
258
|
-
"HostConfig" => {
|
259
|
-
"PortBindings" => {
|
260
|
-
"80/tcp" => [
|
261
|
-
"HostIp" => "0.0.0.0",
|
262
|
-
"HostPort" => port.to_s
|
263
|
-
]
|
264
|
-
}
|
265
|
-
}
|
266
|
-
}
|
267
|
-
end
|
268
245
|
end
|
@@ -0,0 +1,288 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'centurion/service'
|
3
|
+
|
4
|
+
describe Centurion::Service do
|
5
|
+
|
6
|
+
let(:service) { Centurion::Service.new(:redis) }
|
7
|
+
let(:hostname) { 'shakespeare' }
|
8
|
+
let(:image) { 'redis' }
|
9
|
+
|
10
|
+
it 'creates a service from the environment' do
|
11
|
+
extend Capistrano::DSL
|
12
|
+
set_current_environment(:test)
|
13
|
+
set(:name, 'mycontainer')
|
14
|
+
set(:image, image)
|
15
|
+
set(:hostname, hostname)
|
16
|
+
set(:binds, [ Centurion::Service::Volume.new('/foo', '/foo/bar') ])
|
17
|
+
set(:port_bindings, [ Centurion::Service::PortBinding.new(12340, 80, 'tcp') ])
|
18
|
+
|
19
|
+
svc = Centurion::Service.from_env
|
20
|
+
expect(svc.name).to eq('mycontainer')
|
21
|
+
expect(svc.image).to eq(image)
|
22
|
+
expect(svc.dns).to be_nil
|
23
|
+
expect(svc.volumes.size).to eq(1)
|
24
|
+
expect(svc.volumes.first.host_volume).to eq('/foo')
|
25
|
+
expect(svc.port_bindings.size).to eq(1)
|
26
|
+
expect(svc.port_bindings.first.container_port).to eq(80)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'starts with a command' do
|
30
|
+
service.command = ['redis-server']
|
31
|
+
expect(service.command).to eq(['redis-server'])
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'has memory bounds' do
|
35
|
+
service.memory = 1024
|
36
|
+
expect(service.memory).to eq(1024)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'rejects non-numeric memory bounds' do
|
40
|
+
expect(-> { service.memory = 'all' }).to raise_error
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'has cpu shares bounds' do
|
44
|
+
service.cpu_shares = 512
|
45
|
+
expect(service.cpu_shares).to eq(512)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'rejects non-numeric cpu shares' do
|
49
|
+
expect(-> { service.cpu_shares = 'all' }).to raise_error
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'has a custom dns association' do
|
53
|
+
service.dns = 'redis.example.com'
|
54
|
+
expect(service.dns).to eq('redis.example.com')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'boots from a docker image' do
|
58
|
+
service.image = 'registry.hub.docker.com/library/redis'
|
59
|
+
expect(service.image).to eq('registry.hub.docker.com/library/redis')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'has env vars' do
|
63
|
+
service.add_env_vars(SLAVE_OF: '127.0.0.1')
|
64
|
+
service.add_env_vars(USE_AOF: '1')
|
65
|
+
expect(service.env_vars).to eq(SLAVE_OF: '127.0.0.1', USE_AOF: '1')
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'has volume bindings' do
|
69
|
+
service.add_volume('/volumes/redis/data', '/data')
|
70
|
+
service.add_volume('/volumes/redis/config', '/config')
|
71
|
+
expect(service.volumes).to eq([Centurion::Service::Volume.new('/volumes/redis/data', '/data'),
|
72
|
+
Centurion::Service::Volume.new('/volumes/redis/config', '/config')])
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'has port mappings' do
|
76
|
+
service.add_port_bindings(8000, 6379, 'tcp', '127.0.0.1')
|
77
|
+
service.add_port_bindings(18000, 16379, 'tcp', '127.0.0.1')
|
78
|
+
expect(service.port_bindings).to eq([Centurion::Service::PortBinding.new(8000, 6379, 'tcp', '127.0.0.1'),
|
79
|
+
Centurion::Service::PortBinding.new(18000, 16379, 'tcp', '127.0.0.1')])
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'builds a list of public ports for the service' do
|
83
|
+
service.add_port_bindings(8000, 6379, 'tcp', '127.0.0.1')
|
84
|
+
service.add_port_bindings(18000, 16379, 'tcp', '127.0.0.1')
|
85
|
+
expect(service.public_ports).to eq([8000, 18000])
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'building a container configuration' do
|
89
|
+
service = Centurion::Service.new(:redis)
|
90
|
+
service.image = 'http://registry.hub.docker.com/library/redis'
|
91
|
+
service.command = ['redis-server', '--appendonly', 'yes']
|
92
|
+
service.memory = 1024
|
93
|
+
service.cpu_shares = 512
|
94
|
+
service.add_env_vars(SLAVE_OF: '127.0.0.2')
|
95
|
+
service.add_port_bindings(8000, 6379, 'tcp', '10.0.0.1')
|
96
|
+
service.network_mode = 'host'
|
97
|
+
service.add_volume('/volumes/redis.8000', '/data')
|
98
|
+
|
99
|
+
it 'builds a valid docker container configuration' do
|
100
|
+
expect(service.build_config('example.com')).to eq({
|
101
|
+
'Image' => 'http://registry.hub.docker.com/library/redis',
|
102
|
+
'Cmd' => ['redis-server', '--appendonly', 'yes'],
|
103
|
+
'Memory' => 1024,
|
104
|
+
'CpuShares' => 512,
|
105
|
+
'ExposedPorts' => {'6379/tcp' => {}},
|
106
|
+
'Env' => ['SLAVE_OF=127.0.0.2'],
|
107
|
+
'Volumes' => {'/data' => {}},
|
108
|
+
|
109
|
+
# TODO: Ignoring this for now because Docker 1.6
|
110
|
+
# https://github.com/newrelic/centurion/issues/117
|
111
|
+
# 'VolumesFrom' => 'parent'
|
112
|
+
})
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'overrides the default hostname when passed a block' do
|
116
|
+
expect(service.build_config('example.com') { |s| "host.#{s}" }).to eq({
|
117
|
+
'Image' => 'http://registry.hub.docker.com/library/redis',
|
118
|
+
'Hostname' => 'host.example.com',
|
119
|
+
'Cmd' => ['redis-server', '--appendonly', 'yes'],
|
120
|
+
'Memory' => 1024,
|
121
|
+
'CpuShares' => 512,
|
122
|
+
'ExposedPorts' => {'6379/tcp' => {}},
|
123
|
+
'Env' => ['SLAVE_OF=127.0.0.2'],
|
124
|
+
'Volumes' => {'/data' => {}},
|
125
|
+
|
126
|
+
# TODO: Ignoring this for now because Docker 1.6
|
127
|
+
# https://github.com/newrelic/centurion/issues/117
|
128
|
+
# 'VolumesFrom' => 'parent'
|
129
|
+
})
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'interpolates hostname into env variables' do
|
134
|
+
allow(Socket).to receive(:getaddrinfo).and_return([["AF_INET", 0, "93.184.216.34", "93.184.216.34", 2, 1, 6]])
|
135
|
+
service = Centurion::Service.new(:redis)
|
136
|
+
service.add_env_vars(HOST: '%DOCKER_HOSTNAME%')
|
137
|
+
|
138
|
+
expect(service.build_config('example.com')['Env']).to eq(['HOST=example.com'])
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'interpolates host ip into env variables' do
|
142
|
+
allow(Socket).to receive(:getaddrinfo).and_return([["AF_INET", 0, "93.184.216.34", "93.184.216.34", 2, 1, 6]])
|
143
|
+
service = Centurion::Service.new(:redis)
|
144
|
+
service.add_env_vars(HOST: '%DOCKER_HOST_IP%')
|
145
|
+
|
146
|
+
expect(service.build_config('example.com')['Env']).to eq(['HOST=93.184.216.34'])
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'does not blow up on non-string values' do
|
150
|
+
expect { service.add_env_vars(SOMETHING: true) }.not_to raise_error
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'builds a valid docker host configuration' do
|
154
|
+
service = Centurion::Service.new(:redis)
|
155
|
+
service.dns = 'example.com'
|
156
|
+
service.add_port_bindings(8000, 6379)
|
157
|
+
service.cap_adds = ['IPC_BIND', 'NET_RAW']
|
158
|
+
service.cap_drops = ['DAC_OVERRIDE']
|
159
|
+
service.add_volume('/volumes/redis.8000', '/data')
|
160
|
+
|
161
|
+
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('on-failure', 10))).to eq({
|
162
|
+
'Binds' => ['/volumes/redis.8000:/data'],
|
163
|
+
'CapAdd' => ['IPC_BIND', 'NET_RAW'],
|
164
|
+
'CapDrop' => ['DAC_OVERRIDE'],
|
165
|
+
'PortBindings' => {
|
166
|
+
'6379/tcp' => [{'HostPort' => '8000'}]
|
167
|
+
},
|
168
|
+
'NetworkMode' => 'bridge',
|
169
|
+
'Dns' => 'example.com',
|
170
|
+
'RestartPolicy' => {
|
171
|
+
'Name' => 'on-failure',
|
172
|
+
'MaximumRetryCount' => 10
|
173
|
+
}
|
174
|
+
})
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'ignores garbage restart policy' do
|
178
|
+
service = Centurion::Service.new(:redis)
|
179
|
+
|
180
|
+
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('garbage'))).to eq({
|
181
|
+
'Binds' => [],
|
182
|
+
'CapAdd' => [],
|
183
|
+
'CapDrop' => [],
|
184
|
+
'PortBindings' => {},
|
185
|
+
'NetworkMode' => 'bridge',
|
186
|
+
'RestartPolicy' => {
|
187
|
+
'Name' => 'on-failure',
|
188
|
+
'MaximumRetryCount' => 10
|
189
|
+
}
|
190
|
+
})
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'accepts "no" restart policy' do
|
194
|
+
service = Centurion::Service.new(:redis)
|
195
|
+
|
196
|
+
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('no'))).to eq({
|
197
|
+
'Binds' => [],
|
198
|
+
'CapAdd' => [],
|
199
|
+
'CapDrop' => [],
|
200
|
+
'PortBindings' => {},
|
201
|
+
'NetworkMode' => 'bridge',
|
202
|
+
'RestartPolicy' => {
|
203
|
+
'Name' => 'no',
|
204
|
+
}
|
205
|
+
})
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'accepts "always" restart policy' do
|
209
|
+
service = Centurion::Service.new(:redis)
|
210
|
+
|
211
|
+
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('always'))).to eq({
|
212
|
+
'Binds' => [],
|
213
|
+
'CapAdd' => [],
|
214
|
+
'CapDrop' => [],
|
215
|
+
'PortBindings' => {},
|
216
|
+
'NetworkMode' => 'bridge',
|
217
|
+
'RestartPolicy' => {
|
218
|
+
'Name' => 'always',
|
219
|
+
}
|
220
|
+
})
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'accepts "on-failure" restart policy with retry count' do
|
224
|
+
service = Centurion::Service.new(:redis)
|
225
|
+
|
226
|
+
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('on-failure', 50))).to eq({
|
227
|
+
'Binds' => [],
|
228
|
+
'CapAdd' => [],
|
229
|
+
'CapDrop' => [],
|
230
|
+
'NetworkMode' => 'bridge',
|
231
|
+
'PortBindings' => {},
|
232
|
+
'RestartPolicy' => {
|
233
|
+
'Name' => 'on-failure',
|
234
|
+
'MaximumRetryCount' => 50
|
235
|
+
}
|
236
|
+
})
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'builds docker configuration for volume binds' do
|
240
|
+
service.add_volume('/volumes/redis/data', '/data')
|
241
|
+
expect(service.volume_binds_config).to eq(['/volumes/redis/data:/data'])
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'builds docker configuration for port bindings' do
|
245
|
+
service.add_port_bindings(8000, 6379, 'tcp', '127.0.0.1')
|
246
|
+
expect(service.port_bindings_config).to eq({
|
247
|
+
'6379/tcp' => [{'HostPort' => '8000', 'HostIp' => '127.0.0.1'}]
|
248
|
+
})
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'builds docker configuration for port bindings without host ip' do
|
252
|
+
service.add_port_bindings(8000, 6379, 'tcp')
|
253
|
+
expect(service.port_bindings_config).to eq({
|
254
|
+
'6379/tcp' => [{'HostPort' => '8000'}]
|
255
|
+
})
|
256
|
+
end
|
257
|
+
|
258
|
+
it 'builds docker configuration for container-linked networking' do
|
259
|
+
service.network_mode = 'container:a2e8937b'
|
260
|
+
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('on-failure', 50))).to eq({
|
261
|
+
'Binds' => [],
|
262
|
+
'CapAdd' => [],
|
263
|
+
'CapDrop' => [],
|
264
|
+
'NetworkMode' => 'container:a2e8937b',
|
265
|
+
'PortBindings' => {},
|
266
|
+
'RestartPolicy' => {
|
267
|
+
'Name' => 'on-failure',
|
268
|
+
'MaximumRetryCount' => 50
|
269
|
+
}
|
270
|
+
})
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'builds docker configuration for host networking' do
|
274
|
+
service.network_mode = 'host'
|
275
|
+
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('on-failure', 50))).to eq({
|
276
|
+
'Binds' => [],
|
277
|
+
'CapAdd' => [],
|
278
|
+
'CapDrop' => [],
|
279
|
+
'NetworkMode' => 'host',
|
280
|
+
'PortBindings' => {},
|
281
|
+
'RestartPolicy' => {
|
282
|
+
'Name' => 'on-failure',
|
283
|
+
'MaximumRetryCount' => 50
|
284
|
+
}
|
285
|
+
})
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: centurion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.8.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Nic Benders
|
@@ -21,134 +20,118 @@ authors:
|
|
21
20
|
autorequire:
|
22
21
|
bindir: bin
|
23
22
|
cert_chain: []
|
24
|
-
date: 2015-
|
23
|
+
date: 2015-09-08 00:00:00.000000000 Z
|
25
24
|
dependencies:
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: trollop
|
28
27
|
requirement: !ruby/object:Gem::Requirement
|
29
|
-
none: false
|
30
28
|
requirements:
|
31
|
-
- -
|
29
|
+
- - ">="
|
32
30
|
- !ruby/object:Gem::Version
|
33
31
|
version: '0'
|
34
32
|
type: :runtime
|
35
33
|
prerelease: false
|
36
34
|
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
35
|
requirements:
|
39
|
-
- -
|
36
|
+
- - ">="
|
40
37
|
- !ruby/object:Gem::Version
|
41
38
|
version: '0'
|
42
39
|
- !ruby/object:Gem::Dependency
|
43
40
|
name: excon
|
44
41
|
requirement: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
42
|
requirements:
|
47
|
-
- - ~>
|
43
|
+
- - "~>"
|
48
44
|
- !ruby/object:Gem::Version
|
49
45
|
version: '0.33'
|
50
46
|
type: :runtime
|
51
47
|
prerelease: false
|
52
48
|
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
49
|
requirements:
|
55
|
-
- - ~>
|
50
|
+
- - "~>"
|
56
51
|
- !ruby/object:Gem::Version
|
57
52
|
version: '0.33'
|
58
53
|
- !ruby/object:Gem::Dependency
|
59
54
|
name: logger-colors
|
60
55
|
requirement: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
56
|
requirements:
|
63
|
-
- -
|
57
|
+
- - ">="
|
64
58
|
- !ruby/object:Gem::Version
|
65
59
|
version: '0'
|
66
60
|
type: :runtime
|
67
61
|
prerelease: false
|
68
62
|
version_requirements: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
63
|
requirements:
|
71
|
-
- -
|
64
|
+
- - ">="
|
72
65
|
- !ruby/object:Gem::Version
|
73
66
|
version: '0'
|
74
67
|
- !ruby/object:Gem::Dependency
|
75
68
|
name: bundler
|
76
69
|
requirement: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
70
|
requirements:
|
79
|
-
- -
|
71
|
+
- - ">="
|
80
72
|
- !ruby/object:Gem::Version
|
81
73
|
version: '0'
|
82
74
|
type: :development
|
83
75
|
prerelease: false
|
84
76
|
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
77
|
requirements:
|
87
|
-
- -
|
78
|
+
- - ">="
|
88
79
|
- !ruby/object:Gem::Version
|
89
80
|
version: '0'
|
90
81
|
- !ruby/object:Gem::Dependency
|
91
82
|
name: rake
|
92
83
|
requirement: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
84
|
requirements:
|
95
|
-
- -
|
85
|
+
- - ">="
|
96
86
|
- !ruby/object:Gem::Version
|
97
87
|
version: '0'
|
98
88
|
type: :development
|
99
89
|
prerelease: false
|
100
90
|
version_requirements: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
91
|
requirements:
|
103
|
-
- -
|
92
|
+
- - ">="
|
104
93
|
- !ruby/object:Gem::Version
|
105
94
|
version: '0'
|
106
95
|
- !ruby/object:Gem::Dependency
|
107
96
|
name: rspec
|
108
97
|
requirement: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
98
|
requirements:
|
111
|
-
- - ~>
|
99
|
+
- - "~>"
|
112
100
|
- !ruby/object:Gem::Version
|
113
101
|
version: 3.1.0
|
114
102
|
type: :development
|
115
103
|
prerelease: false
|
116
104
|
version_requirements: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
105
|
requirements:
|
119
|
-
- - ~>
|
106
|
+
- - "~>"
|
120
107
|
- !ruby/object:Gem::Version
|
121
108
|
version: 3.1.0
|
122
109
|
- !ruby/object:Gem::Dependency
|
123
110
|
name: pry
|
124
111
|
requirement: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
112
|
requirements:
|
127
|
-
- -
|
113
|
+
- - ">="
|
128
114
|
- !ruby/object:Gem::Version
|
129
115
|
version: '0'
|
130
116
|
type: :development
|
131
117
|
prerelease: false
|
132
118
|
version_requirements: !ruby/object:Gem::Requirement
|
133
|
-
none: false
|
134
119
|
requirements:
|
135
|
-
- -
|
120
|
+
- - ">="
|
136
121
|
- !ruby/object:Gem::Version
|
137
122
|
version: '0'
|
138
123
|
- !ruby/object:Gem::Dependency
|
139
124
|
name: simplecov
|
140
125
|
requirement: !ruby/object:Gem::Requirement
|
141
|
-
none: false
|
142
126
|
requirements:
|
143
|
-
- -
|
127
|
+
- - ">="
|
144
128
|
- !ruby/object:Gem::Version
|
145
129
|
version: '0'
|
146
130
|
type: :development
|
147
131
|
prerelease: false
|
148
132
|
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
none: false
|
150
133
|
requirements:
|
151
|
-
- -
|
134
|
+
- - ">="
|
152
135
|
- !ruby/object:Gem::Version
|
153
136
|
version: '0'
|
154
137
|
description:
|
@@ -172,7 +155,7 @@ executables:
|
|
172
155
|
extensions: []
|
173
156
|
extra_rdoc_files: []
|
174
157
|
files:
|
175
|
-
- .gitignore
|
158
|
+
- ".gitignore"
|
176
159
|
- CONTRIBUTORS.md
|
177
160
|
- Gemfile
|
178
161
|
- LICENSE
|
@@ -192,6 +175,7 @@ files:
|
|
192
175
|
- lib/centurion/docker_via_cli.rb
|
193
176
|
- lib/centurion/dogestry.rb
|
194
177
|
- lib/centurion/logging.rb
|
178
|
+
- lib/centurion/service.rb
|
195
179
|
- lib/centurion/shell.rb
|
196
180
|
- lib/centurion/version.rb
|
197
181
|
- lib/core_ext/numeric_bytes.rb
|
@@ -209,33 +193,33 @@ files:
|
|
209
193
|
- spec/docker_via_cli_spec.rb
|
210
194
|
- spec/dogestry_spec.rb
|
211
195
|
- spec/logging_spec.rb
|
196
|
+
- spec/service_spec.rb
|
212
197
|
- spec/spec_helper.rb
|
213
198
|
- spec/support/matchers/capistrano_dsl_matchers.rb
|
214
199
|
- spec/support/matchers/exit_code_matches.rb
|
215
200
|
homepage: https://github.com/newrelic/centurion
|
216
201
|
licenses:
|
217
202
|
- MIT
|
203
|
+
metadata: {}
|
218
204
|
post_install_message:
|
219
205
|
rdoc_options: []
|
220
206
|
require_paths:
|
221
207
|
- lib
|
222
208
|
required_ruby_version: !ruby/object:Gem::Requirement
|
223
|
-
none: false
|
224
209
|
requirements:
|
225
|
-
- -
|
210
|
+
- - ">="
|
226
211
|
- !ruby/object:Gem::Version
|
227
212
|
version: 1.9.3
|
228
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
|
-
none: false
|
230
214
|
requirements:
|
231
|
-
- -
|
215
|
+
- - ">="
|
232
216
|
- !ruby/object:Gem::Version
|
233
217
|
version: '0'
|
234
218
|
requirements: []
|
235
219
|
rubyforge_project:
|
236
|
-
rubygems_version:
|
220
|
+
rubygems_version: 2.4.5
|
237
221
|
signing_key:
|
238
|
-
specification_version:
|
222
|
+
specification_version: 4
|
239
223
|
summary: A deployment tool for Docker. Takes containers from a Docker registry and
|
240
224
|
runs them on a fleet of hosts with the correct environment variables, host mappings,
|
241
225
|
and port mappings. Supports rolling deployments out of the box, and makes it easy
|
@@ -251,6 +235,7 @@ test_files:
|
|
251
235
|
- spec/docker_via_cli_spec.rb
|
252
236
|
- spec/dogestry_spec.rb
|
253
237
|
- spec/logging_spec.rb
|
238
|
+
- spec/service_spec.rb
|
254
239
|
- spec/spec_helper.rb
|
255
240
|
- spec/support/matchers/capistrano_dsl_matchers.rb
|
256
241
|
- spec/support/matchers/exit_code_matches.rb
|