centurion 1.8.10 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTORS.md +1 -0
- data/README.md +60 -22
- data/centurion.gemspec +2 -0
- data/lib/centurion/deploy_dsl.rb +19 -9
- data/lib/centurion/docker_server.rb +19 -9
- data/lib/centurion/docker_via_api.rb +60 -33
- data/lib/centurion/docker_via_cli.rb +42 -13
- data/lib/centurion/service.rb +10 -1
- data/lib/centurion/ssh.rb +40 -0
- data/lib/centurion/version.rb +1 -1
- data/spec/deploy_dsl_spec.rb +15 -0
- data/spec/docker_via_api_spec.rb +92 -167
- data/spec/docker_via_cli_spec.rb +57 -39
- data/spec/service_spec.rb +5 -1
- data/spec/spec_helper.rb +13 -0
- metadata +52 -23
data/spec/docker_via_cli_spec.rb
CHANGED
@@ -4,27 +4,33 @@ require 'centurion/docker_via_cli'
|
|
4
4
|
describe Centurion::DockerViaCli do
|
5
5
|
let(:docker_path) { 'docker' }
|
6
6
|
|
7
|
-
|
8
|
-
let(:docker_via_cli) { Centurion::DockerViaCli.new('host1', 2375, docker_path) }
|
7
|
+
shared_examples 'docker CLI' do
|
9
8
|
it 'pulls the latest image given its name' do
|
10
9
|
expect(Centurion::Shell).to receive(:echo).
|
11
|
-
with("docker
|
10
|
+
with("docker #{prefix} pull foo:latest")
|
12
11
|
docker_via_cli.pull('foo')
|
13
12
|
end
|
14
13
|
|
15
14
|
it 'pulls an image given its name & tag' do
|
16
15
|
expect(Centurion::Shell).to receive(:echo).
|
17
|
-
with("docker
|
16
|
+
with("docker #{prefix} pull foo:bar")
|
18
17
|
docker_via_cli.pull('foo', 'bar')
|
19
18
|
end
|
20
19
|
|
21
20
|
it 'tails logs on a container' do
|
22
21
|
id = '12345abcdef'
|
23
22
|
expect(Centurion::Shell).to receive(:echo).
|
24
|
-
with("docker
|
23
|
+
with("docker #{prefix} logs -f #{id}")
|
25
24
|
docker_via_cli.tail(id)
|
26
25
|
end
|
27
26
|
|
27
|
+
it 'attach to a container' do
|
28
|
+
id = '12345abcdef'
|
29
|
+
expect(Centurion::Shell).to receive(:echo).
|
30
|
+
with("docker #{prefix} attach #{id}")
|
31
|
+
docker_via_cli.attach(id)
|
32
|
+
end
|
33
|
+
|
28
34
|
it 'should print all chars when one thread is running' do
|
29
35
|
expect(Centurion::Shell).to receive(:run_with_echo)
|
30
36
|
|
@@ -41,51 +47,63 @@ describe Centurion::DockerViaCli do
|
|
41
47
|
docker_via_cli.pull('foo')
|
42
48
|
end
|
43
49
|
end
|
50
|
+
|
51
|
+
context 'without TLS certificates' do
|
52
|
+
let(:docker_via_cli) { Centurion::DockerViaCli.new('host1', 2375, docker_path) }
|
53
|
+
let(:prefix) { "-H=tcp://host1:2375" }
|
54
|
+
|
55
|
+
it_behaves_like 'docker CLI'
|
56
|
+
end
|
57
|
+
|
44
58
|
context 'with TLS certificates' do
|
45
59
|
let(:tls_args) { { tls: true, tlscacert: '/certs/ca.pem',
|
46
60
|
tlscert: '/certs/cert.pem', tlskey: '/certs/key.pem' } }
|
47
61
|
let(:docker_via_cli) { Centurion::DockerViaCli.new('host1', 2375,
|
48
62
|
docker_path, tls_args) }
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
63
|
+
let(:prefix) { "-H=tcp://host1:2375 --tlsverify --tlscacert=/certs/ca.pem --tlscert=/certs/cert.pem --tlskey=/certs/key.pem" }
|
64
|
+
|
65
|
+
it_behaves_like 'docker CLI'
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with a SSH connection' do
|
69
|
+
let(:hostname) { 'host1' }
|
70
|
+
let(:ssh_user) { 'myuser' }
|
71
|
+
let(:ssh_log_level) { nil }
|
72
|
+
let(:docker_via_cli) { Centurion::DockerViaCli.new(hostname, nil, docker_path, params) }
|
73
|
+
let(:prefix) { "-H=unix:///tmp/socket/path" }
|
74
|
+
let(:params) do
|
75
|
+
p = { ssh: true}
|
76
|
+
p[:ssh_user] = ssh_user if ssh_user
|
77
|
+
p[:ssh_log_level] = ssh_log_level if ssh_log_level
|
78
|
+
p
|
57
79
|
end
|
58
80
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
'--tlskey=/certs/key.pem pull foo:bar')
|
66
|
-
docker_via_cli.pull('foo', 'bar')
|
81
|
+
context 'with no log level' do
|
82
|
+
before do
|
83
|
+
expect(Centurion::SSH).to receive(:with_docker_socket).with(hostname, ssh_user, nil).and_yield('/tmp/socket/path')
|
84
|
+
end
|
85
|
+
|
86
|
+
it_behaves_like 'docker CLI'
|
67
87
|
end
|
68
88
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
docker_via_cli.tail(id)
|
89
|
+
context 'with no user' do
|
90
|
+
let(:ssh_user) { nil }
|
91
|
+
|
92
|
+
before do
|
93
|
+
expect(Centurion::SSH).to receive(:with_docker_socket).with(hostname, nil, nil).and_yield('/tmp/socket/path')
|
94
|
+
end
|
95
|
+
|
96
|
+
it_behaves_like 'docker CLI'
|
78
97
|
end
|
79
98
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
docker_via_cli.attach(id)
|
99
|
+
context 'with a log level set' do
|
100
|
+
let(:ssh_log_level) { Logger::DEBUG }
|
101
|
+
|
102
|
+
before do
|
103
|
+
expect(Centurion::SSH).to receive(:with_docker_socket).with(hostname, ssh_user, Logger::DEBUG).and_yield('/tmp/socket/path')
|
104
|
+
end
|
105
|
+
|
106
|
+
it_behaves_like 'docker CLI'
|
89
107
|
end
|
90
108
|
end
|
91
109
|
end
|
data/spec/service_spec.rb
CHANGED
@@ -17,6 +17,7 @@ describe Centurion::Service do
|
|
17
17
|
set(:binds, [ Centurion::Service::Volume.new('/foo', '/foo/bar') ])
|
18
18
|
set(:port_bindings, [ Centurion::Service::PortBinding.new(12340, 80, 'tcp') ])
|
19
19
|
set(:labels, labels)
|
20
|
+
set(:security_opt, ['seccomp=unconfined'])
|
20
21
|
|
21
22
|
svc = Centurion::Service.from_env
|
22
23
|
expect(svc.name).to eq('mycontainer')
|
@@ -27,6 +28,7 @@ describe Centurion::Service do
|
|
27
28
|
expect(svc.port_bindings.size).to eq(1)
|
28
29
|
expect(svc.port_bindings.first.container_port).to eq(80)
|
29
30
|
expect(svc.labels).to eq(labels)
|
31
|
+
expect(svc.security_opt).to eq(['seccomp=unconfined'])
|
30
32
|
end
|
31
33
|
|
32
34
|
it 'starts with a command' do
|
@@ -171,6 +173,7 @@ describe Centurion::Service do
|
|
171
173
|
service.cap_adds = ['IPC_BIND', 'NET_RAW']
|
172
174
|
service.cap_drops = ['DAC_OVERRIDE']
|
173
175
|
service.add_volume('/volumes/redis.8000', '/data')
|
176
|
+
service.security_opt = 'seccomp=unconfined'
|
174
177
|
|
175
178
|
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('on-failure', 10))).to eq({
|
176
179
|
'Binds' => ['/volumes/redis.8000:/data'],
|
@@ -184,7 +187,8 @@ describe Centurion::Service do
|
|
184
187
|
'RestartPolicy' => {
|
185
188
|
'Name' => 'on-failure',
|
186
189
|
'MaximumRetryCount' => 10
|
187
|
-
}
|
190
|
+
},
|
191
|
+
'SecurityOpt' => 'seccomp=unconfined'
|
188
192
|
})
|
189
193
|
end
|
190
194
|
|
data/spec/spec_helper.rb
CHANGED
@@ -3,5 +3,18 @@ SimpleCov.start do
|
|
3
3
|
add_filter '/spec'
|
4
4
|
end
|
5
5
|
|
6
|
+
require 'excon'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
# Mock by default
|
10
|
+
config.before(:all) do
|
11
|
+
Excon.defaults[:mock] = true
|
12
|
+
end
|
13
|
+
|
14
|
+
config.after(:each) do
|
15
|
+
Excon.stubs.clear
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
6
19
|
$: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
20
|
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each {|f| require f}
|
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.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nic Benders
|
@@ -20,118 +20,146 @@ authors:
|
|
20
20
|
autorequire:
|
21
21
|
bindir: bin
|
22
22
|
cert_chain: []
|
23
|
-
date: 2017-
|
23
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: trollop
|
27
27
|
requirement: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
|
-
- -
|
29
|
+
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: '0'
|
32
32
|
type: :runtime
|
33
33
|
prerelease: false
|
34
34
|
version_requirements: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- -
|
36
|
+
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: excon
|
41
41
|
requirement: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- - ~>
|
43
|
+
- - "~>"
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0.33'
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- - ~>
|
50
|
+
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0.33'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: logger-colors
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- -
|
57
|
+
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
60
|
type: :runtime
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- -
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: net-ssh
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: sshkit
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
65
93
|
- !ruby/object:Gem::Version
|
66
94
|
version: '0'
|
67
95
|
- !ruby/object:Gem::Dependency
|
68
96
|
name: bundler
|
69
97
|
requirement: !ruby/object:Gem::Requirement
|
70
98
|
requirements:
|
71
|
-
- -
|
99
|
+
- - ">="
|
72
100
|
- !ruby/object:Gem::Version
|
73
101
|
version: '0'
|
74
102
|
type: :development
|
75
103
|
prerelease: false
|
76
104
|
version_requirements: !ruby/object:Gem::Requirement
|
77
105
|
requirements:
|
78
|
-
- -
|
106
|
+
- - ">="
|
79
107
|
- !ruby/object:Gem::Version
|
80
108
|
version: '0'
|
81
109
|
- !ruby/object:Gem::Dependency
|
82
110
|
name: rake
|
83
111
|
requirement: !ruby/object:Gem::Requirement
|
84
112
|
requirements:
|
85
|
-
- - ~>
|
113
|
+
- - "~>"
|
86
114
|
- !ruby/object:Gem::Version
|
87
115
|
version: '10.5'
|
88
116
|
type: :development
|
89
117
|
prerelease: false
|
90
118
|
version_requirements: !ruby/object:Gem::Requirement
|
91
119
|
requirements:
|
92
|
-
- - ~>
|
120
|
+
- - "~>"
|
93
121
|
- !ruby/object:Gem::Version
|
94
122
|
version: '10.5'
|
95
123
|
- !ruby/object:Gem::Dependency
|
96
124
|
name: rspec
|
97
125
|
requirement: !ruby/object:Gem::Requirement
|
98
126
|
requirements:
|
99
|
-
- - ~>
|
127
|
+
- - "~>"
|
100
128
|
- !ruby/object:Gem::Version
|
101
129
|
version: 3.1.0
|
102
130
|
type: :development
|
103
131
|
prerelease: false
|
104
132
|
version_requirements: !ruby/object:Gem::Requirement
|
105
133
|
requirements:
|
106
|
-
- - ~>
|
134
|
+
- - "~>"
|
107
135
|
- !ruby/object:Gem::Version
|
108
136
|
version: 3.1.0
|
109
137
|
- !ruby/object:Gem::Dependency
|
110
138
|
name: pry
|
111
139
|
requirement: !ruby/object:Gem::Requirement
|
112
140
|
requirements:
|
113
|
-
- -
|
141
|
+
- - ">="
|
114
142
|
- !ruby/object:Gem::Version
|
115
143
|
version: '0'
|
116
144
|
type: :development
|
117
145
|
prerelease: false
|
118
146
|
version_requirements: !ruby/object:Gem::Requirement
|
119
147
|
requirements:
|
120
|
-
- -
|
148
|
+
- - ">="
|
121
149
|
- !ruby/object:Gem::Version
|
122
150
|
version: '0'
|
123
151
|
- !ruby/object:Gem::Dependency
|
124
152
|
name: simplecov
|
125
153
|
requirement: !ruby/object:Gem::Requirement
|
126
154
|
requirements:
|
127
|
-
- -
|
155
|
+
- - ">="
|
128
156
|
- !ruby/object:Gem::Version
|
129
157
|
version: '0'
|
130
158
|
type: :development
|
131
159
|
prerelease: false
|
132
160
|
version_requirements: !ruby/object:Gem::Requirement
|
133
161
|
requirements:
|
134
|
-
- -
|
162
|
+
- - ">="
|
135
163
|
- !ruby/object:Gem::Version
|
136
164
|
version: '0'
|
137
165
|
description:
|
@@ -155,8 +183,8 @@ executables:
|
|
155
183
|
extensions: []
|
156
184
|
extra_rdoc_files: []
|
157
185
|
files:
|
158
|
-
- .gitignore
|
159
|
-
- .travis.yml
|
186
|
+
- ".gitignore"
|
187
|
+
- ".travis.yml"
|
160
188
|
- CONTRIBUTORS.md
|
161
189
|
- Gemfile
|
162
190
|
- LICENSE
|
@@ -178,6 +206,7 @@ files:
|
|
178
206
|
- lib/centurion/logging.rb
|
179
207
|
- lib/centurion/service.rb
|
180
208
|
- lib/centurion/shell.rb
|
209
|
+
- lib/centurion/ssh.rb
|
181
210
|
- lib/centurion/version.rb
|
182
211
|
- lib/core_ext/numeric_bytes.rb
|
183
212
|
- lib/tasks/centurion.rake
|
@@ -208,17 +237,17 @@ require_paths:
|
|
208
237
|
- lib
|
209
238
|
required_ruby_version: !ruby/object:Gem::Requirement
|
210
239
|
requirements:
|
211
|
-
- -
|
240
|
+
- - ">="
|
212
241
|
- !ruby/object:Gem::Version
|
213
242
|
version: 1.9.3
|
214
243
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
244
|
requirements:
|
216
|
-
- -
|
245
|
+
- - ">="
|
217
246
|
- !ruby/object:Gem::Version
|
218
247
|
version: '0'
|
219
248
|
requirements: []
|
220
249
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.
|
250
|
+
rubygems_version: 2.5.2
|
222
251
|
signing_key:
|
223
252
|
specification_version: 4
|
224
253
|
summary: A deployment tool for Docker. Takes containers from a Docker registry and
|