centurion 1.3.1 → 1.4.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.
- data/README.md +64 -5
- data/bin/centurion +2 -2
- data/lib/centurion/deploy.rb +3 -3
- data/lib/centurion/deploy_dsl.rb +21 -5
- data/lib/centurion/docker_server.rb +6 -3
- data/lib/centurion/docker_server_group.rb +5 -3
- data/lib/centurion/docker_via_api.rb +33 -9
- data/lib/centurion/docker_via_cli.rb +45 -5
- data/lib/centurion/dogestry.rb +6 -19
- data/lib/centurion/version.rb +1 -1
- data/lib/tasks/deploy.rake +12 -17
- data/spec/capistrano_dsl_spec.rb +1 -1
- data/spec/deploy_dsl_spec.rb +1 -1
- data/spec/deploy_spec.rb +66 -35
- data/spec/docker_server_group_spec.rb +1 -1
- data/spec/docker_server_spec.rb +2 -2
- data/spec/docker_via_api_spec.rb +211 -76
- data/spec/docker_via_cli_spec.rb +74 -25
- data/spec/dogestry_spec.rb +14 -7
- data/spec/support/matchers/capistrano_dsl_matchers.rb +2 -2
- metadata +2 -2
data/spec/docker_via_cli_spec.rb
CHANGED
@@ -3,40 +3,89 @@ require 'centurion/docker_via_cli'
|
|
3
3
|
|
4
4
|
describe Centurion::DockerViaCli do
|
5
5
|
let(:docker_path) { 'docker' }
|
6
|
-
let(:docker_via_cli) { Centurion::DockerViaCli.new('host1', 2375, docker_path) }
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
context 'without TLS certificates' do
|
8
|
+
let(:docker_via_cli) { Centurion::DockerViaCli.new('host1', 2375, docker_path) }
|
9
|
+
it 'pulls the latest image given its name' do
|
10
|
+
expect(docker_via_cli).to receive(:echo).
|
11
|
+
with("docker -H=tcp://host1:2375 pull foo:latest")
|
12
|
+
docker_via_cli.pull('foo')
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
it 'pulls an image given its name & tag' do
|
16
|
+
expect(docker_via_cli).to receive(:echo).
|
17
|
+
with("docker -H=tcp://host1:2375 pull foo:bar")
|
18
|
+
docker_via_cli.pull('foo', 'bar')
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
it 'tails logs on a container' do
|
22
|
+
id = '12345abcdef'
|
23
|
+
expect(docker_via_cli).to receive(:echo).
|
24
|
+
with("docker -H=tcp://host1:2375 logs -f #{id}")
|
25
|
+
docker_via_cli.tail(id)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should print all chars when one thread is running' do
|
29
|
+
expect(docker_via_cli).to receive(:run_with_echo)
|
30
|
+
|
31
|
+
allow(Thread).to receive(:list) {[double(:status => 'run')]}
|
32
|
+
|
33
|
+
docker_via_cli.pull('foo')
|
34
|
+
end
|
26
35
|
|
27
|
-
|
28
|
-
|
36
|
+
it 'should only print lines when multiple threads are running' do
|
37
|
+
expect(docker_via_cli).to receive(:run_without_echo)
|
29
38
|
|
30
|
-
|
39
|
+
allow(Thread).to receive(:list) {[double(:status => 'run'), double(:status => 'run')]}
|
31
40
|
|
32
|
-
|
41
|
+
docker_via_cli.pull('foo')
|
42
|
+
end
|
33
43
|
end
|
44
|
+
context 'with TLS certificates' do
|
45
|
+
let(:tls_args) { { tls: true, tlscacert: '/certs/ca.pem',
|
46
|
+
tlscert: '/certs/cert.pem', tlskey: '/certs/key.pem' } }
|
47
|
+
let(:docker_via_cli) { Centurion::DockerViaCli.new('host1', 2375,
|
48
|
+
docker_path, tls_args) }
|
49
|
+
it 'pulls the latest image given its name' do
|
50
|
+
expect(docker_via_cli).to receive(:echo).
|
51
|
+
with('docker -H=tcp://host1:2375 ' \
|
52
|
+
'--tlsverify ' \
|
53
|
+
'--tlscacert=/certs/ca.pem ' \
|
54
|
+
'--tlscert=/certs/cert.pem ' \
|
55
|
+
'--tlskey=/certs/key.pem pull foo:latest')
|
56
|
+
docker_via_cli.pull('foo')
|
57
|
+
end
|
34
58
|
|
35
|
-
|
36
|
-
|
59
|
+
it 'pulls an image given its name & tag' do
|
60
|
+
expect(docker_via_cli).to receive(:echo).
|
61
|
+
with('docker -H=tcp://host1:2375 ' \
|
62
|
+
'--tlsverify ' \
|
63
|
+
'--tlscacert=/certs/ca.pem ' \
|
64
|
+
'--tlscert=/certs/cert.pem ' \
|
65
|
+
'--tlskey=/certs/key.pem pull foo:bar')
|
66
|
+
docker_via_cli.pull('foo', 'bar')
|
67
|
+
end
|
37
68
|
|
38
|
-
|
69
|
+
it 'tails logs on a container' do
|
70
|
+
id = '12345abcdef'
|
71
|
+
expect(docker_via_cli).to receive(:echo).
|
72
|
+
with('docker -H=tcp://host1:2375 ' \
|
73
|
+
'--tlsverify ' \
|
74
|
+
'--tlscacert=/certs/ca.pem ' \
|
75
|
+
'--tlscert=/certs/cert.pem ' \
|
76
|
+
"--tlskey=/certs/key.pem logs -f #{id}")
|
77
|
+
docker_via_cli.tail(id)
|
78
|
+
end
|
39
79
|
|
40
|
-
|
80
|
+
it 'attach to a container' do
|
81
|
+
id = '12345abcdef'
|
82
|
+
expect(docker_via_cli).to receive(:echo).
|
83
|
+
with('docker -H=tcp://host1:2375 ' \
|
84
|
+
'--tlsverify ' \
|
85
|
+
'--tlscacert=/certs/ca.pem ' \
|
86
|
+
'--tlscert=/certs/cert.pem ' \
|
87
|
+
"--tlskey=/certs/key.pem attach #{id}")
|
88
|
+
docker_via_cli.attach(id)
|
89
|
+
end
|
41
90
|
end
|
42
91
|
end
|
data/spec/dogestry_spec.rb
CHANGED
@@ -14,44 +14,51 @@ describe Centurion::Dogestry do
|
|
14
14
|
|
15
15
|
describe '#aws_access_key_id' do
|
16
16
|
it 'returns correct value' do
|
17
|
-
registry.aws_access_key_id.
|
17
|
+
expect(registry.aws_access_key_id).to eq(dogestry_options[:aws_access_key_id])
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#aws_secret_key' do
|
22
22
|
it 'returns correct value' do
|
23
|
-
registry.aws_secret_key.
|
23
|
+
expect(registry.aws_secret_key).to eq(dogestry_options[:aws_secret_key])
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#s3_bucket' do
|
28
28
|
it 'returns correct value' do
|
29
|
-
registry.s3_bucket.
|
29
|
+
expect(registry.s3_bucket).to eq(dogestry_options[:s3_bucket])
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#s3_region' do
|
34
34
|
it 'returns correct default value' do
|
35
|
-
registry.s3_region.
|
35
|
+
expect(registry.s3_region).to eq("us-east-1")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '#s3_url' do
|
40
40
|
it 'returns correct value' do
|
41
|
-
registry.s3_url.
|
41
|
+
expect(registry.s3_url).to eq("s3://#{registry.s3_bucket}/?region=#{registry.s3_region}")
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe '#exec_command' do
|
46
46
|
it 'returns correct value' do
|
47
|
-
registry.exec_command('pull', repo).
|
47
|
+
expect(registry.exec_command('pull', repo)).to start_with('dogestry')
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
describe '#pull' do
|
52
|
+
it 'returns correct value' do
|
53
|
+
expect(registry).to receive(:echo).with("dogestry #{flags} pull #{registry.s3_url} #{repo}")
|
54
|
+
registry.pull(repo, pull_hosts)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
51
58
|
describe '#which' do
|
52
59
|
it 'finds dogestry command line' do
|
53
60
|
allow(File).to receive(:executable?).and_return(true)
|
54
|
-
registry.which('dogestry').
|
61
|
+
expect(registry.which('dogestry')).to_not be_nil
|
55
62
|
end
|
56
63
|
end
|
57
64
|
end
|
@@ -3,11 +3,11 @@ RSpec::Matchers.define :have_key_and_value do |expected_key, expected_value|
|
|
3
3
|
actual.env[actual.current_environment].has_key?(expected_key.to_sym) && (actual.fetch(expected_key.to_sym) == expected_value)
|
4
4
|
end
|
5
5
|
|
6
|
-
|
6
|
+
failure_message do |actual|
|
7
7
|
"expected that #{actual.env[actual.current_environment].keys.inspect} would include #{expected_key.inspect} with value #{expected_value.inspect}"
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
failure_message_when_negated do |actual|
|
11
11
|
"expected that #{actual.env[actual.current_environment].keys.join(', ')} would not include #{expected_key.inspect} with value #{expected_value.inspect}"
|
12
12
|
end
|
13
13
|
end
|
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.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -21,7 +21,7 @@ authors:
|
|
21
21
|
autorequire:
|
22
22
|
bindir: bin
|
23
23
|
cert_chain: []
|
24
|
-
date:
|
24
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
25
25
|
dependencies:
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: trollop
|