hoosegow 1.2.5 → 1.2.6
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 +5 -5
- data/hoosegow.gemspec +2 -2
- data/lib/hoosegow/docker.rb +7 -17
- data/spec/hoosegow_docker_spec.rb +27 -6
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e39782e9a5c8b68841412a3c05965f2f1fff65930971832c821f387250e24679
|
4
|
+
data.tar.gz: 8dc38e89647af50f078a7a1e14e2e4f8834c13a4ebeafbacb1044ee93fc125db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32625371ed542ffec17e775e837bd946db3717aea5f810236c2f1d44614c09469d68ea3073dcc87c035e7d4b7080b1e22727388990283994754b4feb49d3d996
|
7
|
+
data.tar.gz: 8404be59505bf62095bba370d4f61dedc2b88ba912c7eb22ae08d5e316a90f201e3f7f8bfb6b05a5901c89fc7dfa2e9f726e60d61febd69a6c7ceddefabc75aa
|
data/hoosegow.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'hoosegow'
|
3
|
-
s.version = '1.2.
|
3
|
+
s.version = '1.2.6'
|
4
4
|
s.summary = "A Docker jail for ruby code"
|
5
5
|
s.description = "Hoosegow provides an RPC layer on top of Docker containers so that you can isolate unsafe parts of your application."
|
6
6
|
s.authors = ["Ben Toews", "Matt Burke"]
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.required_ruby_version = ">= 1.9.3"
|
25
25
|
s.add_development_dependency 'rake'
|
26
26
|
s.add_development_dependency 'rspec', '>= 2.14.1', '~> 2.14'
|
27
|
-
s.add_runtime_dependency 'msgpack', '
|
27
|
+
s.add_runtime_dependency 'msgpack', '~> 1.0.0'
|
28
28
|
s.add_runtime_dependency 'yajl-ruby', '>= 1.1.0', '~> 1.1'
|
29
29
|
s.add_runtime_dependency 'docker-api', '~> 1.19'
|
30
30
|
end
|
data/lib/hoosegow/docker.rb
CHANGED
@@ -80,9 +80,11 @@ class Hoosegow
|
|
80
80
|
# Returns nothing.
|
81
81
|
def create_container(image)
|
82
82
|
@container = ::Docker::Container.create @container_options.merge(
|
83
|
-
:StdinOnce
|
84
|
-
:OpenStdin
|
85
|
-
:
|
83
|
+
:StdinOnce => true,
|
84
|
+
:OpenStdin => true,
|
85
|
+
:HostConfig => {
|
86
|
+
:Binds => volumes_for_bind
|
87
|
+
},
|
86
88
|
:Image => image
|
87
89
|
)
|
88
90
|
callback @after_create
|
@@ -92,7 +94,7 @@ class Hoosegow
|
|
92
94
|
#
|
93
95
|
# Returns nothing.
|
94
96
|
def start_container
|
95
|
-
@container.start
|
97
|
+
@container.start
|
96
98
|
callback @after_start
|
97
99
|
end
|
98
100
|
|
@@ -200,19 +202,7 @@ class Hoosegow
|
|
200
202
|
end
|
201
203
|
end
|
202
204
|
|
203
|
-
# Private: Generate the `
|
204
|
-
#
|
205
|
-
# Given a hash of container_path => local_path in @volumes, generate a
|
206
|
-
# hash of container_path => {}.
|
207
|
-
def volumes_for_create
|
208
|
-
result = {}
|
209
|
-
each_volume do |container_path, local_path, permissions|
|
210
|
-
result[container_path] = {}
|
211
|
-
end
|
212
|
-
result
|
213
|
-
end
|
214
|
-
|
215
|
-
# Private: Generate the `Binds` argument for starting a container.
|
205
|
+
# Private: Generate the `Binds` argument for creating a container.
|
216
206
|
#
|
217
207
|
# Given a hash of container_path => local_path in @volumes, generate an
|
218
208
|
# array of "local_path:container_path:rw".
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require_relative '../lib/hoosegow'
|
2
3
|
|
3
4
|
unless defined?(CONFIG)
|
@@ -18,13 +19,11 @@ describe Hoosegow::Docker do
|
|
18
19
|
|
19
20
|
context 'unspecified' do
|
20
21
|
subject { described_class.new }
|
21
|
-
its(:volumes_for_create) { should be_empty }
|
22
22
|
its(:volumes_for_bind) { should be_empty }
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'empty' do
|
26
26
|
let(:volumes) { {} }
|
27
|
-
its(:volumes_for_create) { should be_empty }
|
28
27
|
its(:volumes_for_bind) { should be_empty }
|
29
28
|
end
|
30
29
|
|
@@ -33,10 +32,6 @@ describe Hoosegow::Docker do
|
|
33
32
|
"/inside/path" => "/home/burke/data-for-container:rw",
|
34
33
|
"/other/path" => "/etc/shared-config",
|
35
34
|
} }
|
36
|
-
its(:volumes_for_create) { should == {
|
37
|
-
"/inside/path" => {},
|
38
|
-
"/other/path" => {},
|
39
|
-
} }
|
40
35
|
its(:volumes_for_bind) { should == [
|
41
36
|
"/home/burke/data-for-container:/inside/path:rw",
|
42
37
|
"/etc/shared-config:/other/path:ro",
|
@@ -44,6 +39,32 @@ describe Hoosegow::Docker do
|
|
44
39
|
end
|
45
40
|
end
|
46
41
|
|
42
|
+
context "volume is writable" do
|
43
|
+
it "calls after_create" do
|
44
|
+
test_dir = File.join(Dir.pwd, 'volume-test')
|
45
|
+
FileUtils.remove_dir(test_dir, true)
|
46
|
+
FileUtils.mkpath(test_dir)
|
47
|
+
|
48
|
+
config = CONFIG.merge(
|
49
|
+
:Entrypoint => ['/usr/bin/touch', '/volume-test/test'],
|
50
|
+
:volumes => { '/volume-test' => test_dir + ":rw"}
|
51
|
+
)
|
52
|
+
docker = Hoosegow::Docker.new(config)
|
53
|
+
begin
|
54
|
+
docker.create_container CONFIG[:image_name]
|
55
|
+
docker.start_container
|
56
|
+
ensure
|
57
|
+
docker.stop_container
|
58
|
+
docker.delete_container
|
59
|
+
end
|
60
|
+
|
61
|
+
exists = File.exists?(File.join(test_dir, 'test'))
|
62
|
+
expect(exists).to be_truthy
|
63
|
+
FileUtils.remove_dir(test_dir, true)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
47
68
|
context 'docker_url' do
|
48
69
|
it "correctly generates TCP urls" do
|
49
70
|
hoosegow = Hoosegow::Docker.new CONFIG.merge(:host => "1.1.1.1", :port => 1234)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoosegow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Toews
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -49,22 +49,16 @@ dependencies:
|
|
49
49
|
name: msgpack
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.5.6
|
55
52
|
- - "~>"
|
56
53
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
54
|
+
version: 1.0.0
|
58
55
|
type: :runtime
|
59
56
|
prerelease: false
|
60
57
|
version_requirements: !ruby/object:Gem::Requirement
|
61
58
|
requirements:
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: 0.5.6
|
65
59
|
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
61
|
+
version: 1.0.0
|
68
62
|
- !ruby/object:Gem::Dependency
|
69
63
|
name: yajl-ruby
|
70
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
142
|
version: '0'
|
149
143
|
requirements: []
|
150
144
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
145
|
+
rubygems_version: 2.7.6
|
152
146
|
signing_key:
|
153
147
|
specification_version: 4
|
154
148
|
summary: A Docker jail for ruby code
|