dry-dock 0.1.3 → 0.1.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 +4 -4
- data/VERSION +1 -1
- data/dry-dock.gemspec +3 -3
- data/lib/drydock/errors.rb +3 -0
- data/lib/drydock/phase_chain.rb +40 -6
- data/spec/drydock/project_import_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5de350e13158e99318eabbb68b7d507804cb0c9c
|
4
|
+
data.tar.gz: df476fedf7609cf0734aa92aaae0ab71235aa2df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 562e59af24727a8d9a23a2e8a677386b70a5bcadd48969af33a0c595c3c5592d68bd90cf72cc913a111bf4c27127ac03e051ce01aa114aa4d7db1e5189522183
|
7
|
+
data.tar.gz: f5807ebf5764c81c1fdef2e9c7650fc0e57f97608e305c586a18dcfe04fb46ef9a450d4c00085c1be94f181c1353df0da1719a4bf7f141d1f1e2bd23a4e64ba6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/dry-dock.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: dry-dock 0.1.
|
5
|
+
# stub: dry-dock 0.1.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "dry-dock"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Ripta Pasay"]
|
14
|
-
s.date = "2015-10-
|
14
|
+
s.date = "2015-10-02"
|
15
15
|
s.description = "A Dockerfile-replacement DSL for building complex images"
|
16
16
|
s.email = "github@r8y.org"
|
17
17
|
s.executables = ["drydock", "json-test-consumer.rb", "json-test-producer.rb", "test-tar-writer-digest.rb"]
|
data/lib/drydock/errors.rb
CHANGED
data/lib/drydock/phase_chain.rb
CHANGED
@@ -55,11 +55,15 @@ module Drydock
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
# TODO(rpasay): Break this large method apart.
|
58
59
|
def self.create_container(cfg, &blk)
|
59
60
|
meta_options = cfg[:MetaOptions] || {}
|
60
61
|
timeout = meta_options.fetch(:read_timeout, Excon.defaults[:read_timeout]) || 60
|
61
62
|
|
62
63
|
Docker::Container.create(cfg).tap do |c|
|
64
|
+
# The call to Container.create merely creates a container, to be
|
65
|
+
# scheduled to run. Start a separate thread that attaches to the
|
66
|
+
# container's streams and mirror them to the logger.
|
63
67
|
t = Thread.new do
|
64
68
|
begin
|
65
69
|
c.attach(stream: true, stdout: true, stderr: true) do |stream, chunk|
|
@@ -78,12 +82,44 @@ module Drydock
|
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
81
|
-
|
85
|
+
# TODO(rpasay): RACE CONDITION POSSIBLE - the thread above may be
|
86
|
+
# scheduled but not run before this block gets executed, which can
|
87
|
+
# cause a loss of log output. However, forcing `t` to be run once
|
88
|
+
# before this point seems to cause an endless wait (ruby 2.1.5).
|
89
|
+
# Need to dig deeper in the future.
|
90
|
+
#
|
91
|
+
# TODO(rpasay): More useful `blk` handling here. This method only
|
92
|
+
# returns after the container terminates, which isn't useful when
|
93
|
+
# you want to do stuff to it, e.g., spawn a new exec container.
|
94
|
+
#
|
95
|
+
# The following block starts the container, and waits for it to finish.
|
96
|
+
# An error is raised if no exit code is returned or if the exit code
|
97
|
+
# is non-zero.
|
98
|
+
begin
|
99
|
+
c.start
|
100
|
+
blk.call(c) if blk
|
101
|
+
|
102
|
+
results = c.wait(timeout)
|
103
|
+
|
104
|
+
unless results
|
105
|
+
raise InvalidCommandExecutionError, {container: c.id, message: "Container did not return anything (API BUG?)"}
|
106
|
+
end
|
82
107
|
|
83
|
-
|
108
|
+
unless results.key?('StatusCode')
|
109
|
+
raise InvalidCommandExecutionError, {container: c.id, message: "Container did not return a status code (API BUG?)"}
|
110
|
+
end
|
84
111
|
|
85
|
-
|
86
|
-
|
112
|
+
unless results['StatusCode'] == 0
|
113
|
+
raise InvalidCommandExecutionError, {container: c.id, message: "Container exited with code #{results['StatusCode']}"}
|
114
|
+
end
|
115
|
+
rescue
|
116
|
+
# on error, kill the streaming logs and reraise the exception
|
117
|
+
t.kill
|
118
|
+
raise
|
119
|
+
ensure
|
120
|
+
# always rejoin the thread
|
121
|
+
t.join
|
122
|
+
end
|
87
123
|
end
|
88
124
|
end
|
89
125
|
|
@@ -210,8 +246,6 @@ module Drydock
|
|
210
246
|
end
|
211
247
|
|
212
248
|
commit_config = self.class.build_commit_opts(opts)
|
213
|
-
Drydock.logger.info(opts.inspect)
|
214
|
-
Drydock.logger.info(commit_config.inspect)
|
215
249
|
|
216
250
|
result = container.commit(commit_config)
|
217
251
|
Drydock.logger.info(message: "Committed image ID #{result.id.slice(0, 12)}")
|
@@ -36,4 +36,14 @@ RSpec.describe Drydock::Project do
|
|
36
36
|
expect(v2_output).to include("'/tmp/VERSION': No such file or directory")
|
37
37
|
end
|
38
38
|
|
39
|
+
it 'succeeds running a real command' do
|
40
|
+
project.from('alpine')
|
41
|
+
expect { project.run('ls /') }.not_to raise_error
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'fails running a non-existant command' do
|
45
|
+
project.from('alpine')
|
46
|
+
expect { project.run('whatever-gonna-error /') }.to raise_error(Drydock::InvalidCommandExecutionError)
|
47
|
+
end
|
48
|
+
|
39
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-dock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ripta Pasay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|