hoosegow 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: e39782e9a5c8b68841412a3c05965f2f1fff65930971832c821f387250e24679
4
- data.tar.gz: 8dc38e89647af50f078a7a1e14e2e4f8834c13a4ebeafbacb1044ee93fc125db
2
+ SHA1:
3
+ metadata.gz: 615d6ccef6061219fdf2537bc99e1ead31ab30e8
4
+ data.tar.gz: d3fc67b40b2866d1ea76138c13c14228d0fd700b
5
5
  SHA512:
6
- metadata.gz: 32625371ed542ffec17e775e837bd946db3717aea5f810236c2f1d44614c09469d68ea3073dcc87c035e7d4b7080b1e22727388990283994754b4feb49d3d996
7
- data.tar.gz: 8404be59505bf62095bba370d4f61dedc2b88ba912c7eb22ae08d5e316a90f201e3f7f8bfb6b05a5901c89fc7dfa2e9f726e60d61febd69a6c7ceddefabc75aa
6
+ metadata.gz: 58a899e06faee750afc8b43a120f702cdfb417d0a67e66672ddbb6d1366b3d1b97aae0946ec1155d49c3289d587026935231927b01cf36a98faad89c55aea9a3
7
+ data.tar.gz: 521df958416b7f6a213ca2ef7d452f7f924074bca01b1bd1cf78ad45118fcb60bf300622c6b661127fb060c905b70dc2fcff67c1bd7237302bcfe16685ca9b82
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'hoosegow'
3
- s.version = '1.2.6'
3
+ s.version = '1.2.7'
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"]
@@ -79,13 +79,15 @@ class Hoosegow
79
79
  #
80
80
  # Returns nothing.
81
81
  def create_container(image)
82
+ create_options = default_container_options(image)
83
+
84
+ # Merge in additional :HostConfig options into default options
85
+ if @container_options.has_key?(:HostConfig)
86
+ create_options[:HostConfig].merge!(@container_options[:HostConfig])
87
+ end
88
+
82
89
  @container = ::Docker::Container.create @container_options.merge(
83
- :StdinOnce => true,
84
- :OpenStdin => true,
85
- :HostConfig => {
86
- :Binds => volumes_for_bind
87
- },
88
- :Image => image
90
+ create_options
89
91
  )
90
92
  callback @after_create
91
93
  end
@@ -172,6 +174,19 @@ class Hoosegow
172
174
  end
173
175
 
174
176
  private
177
+
178
+ # Private: Default options used to create containers
179
+ def default_container_options(image)
180
+ {
181
+ :StdinOnce => true,
182
+ :OpenStdin => true,
183
+ :HostConfig => {
184
+ :Binds => volumes_for_bind
185
+ },
186
+ :Image => image
187
+ }
188
+ end
189
+
175
190
  # Private: Set the docker URL, if related options are present.
176
191
  def set_docker_url!(options)
177
192
  if url = docker_url(options)
@@ -64,6 +64,38 @@ describe Hoosegow::Docker do
64
64
  end
65
65
  end
66
66
 
67
+ context "with custom connection options" do
68
+ before(:each) {
69
+ FileUtils.remove_dir(test_dir, true)
70
+ FileUtils.mkpath(test_dir)
71
+ }
72
+ after { FileUtils.remove_dir(test_dir, true) }
73
+
74
+ let(:test_dir) { File.join(Dir.pwd, 'volume-test') }
75
+
76
+ it "configures ExtraHosts option" do
77
+ config = CONFIG.merge(
78
+ :Entrypoint => ['/bin/sh', '-c', 'getent hosts some-service > /volume-test/out.txt'],
79
+ :volumes => { '/volume-test' => test_dir + ":rw"},
80
+ :HostConfig => {
81
+ :ExtraHosts => ["some-service:127.0.0.1"]
82
+ }
83
+ )
84
+ docker = Hoosegow::Docker.new(config)
85
+ begin
86
+ docker.create_container CONFIG[:image_name]
87
+ docker.start_container
88
+ ensure
89
+ docker.stop_container
90
+ docker.delete_container
91
+ end
92
+
93
+ # Ensure ExtraHosts config is set
94
+ contents = File.read(File.join(test_dir, 'out.txt'))
95
+ expect(contents).to match("127.0.0.1\s+some-service")
96
+ end
97
+ end
98
+
67
99
 
68
100
  context 'docker_url' do
69
101
  it "correctly generates TCP urls" do
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.6
4
+ version: 1.2.7
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: 2018-04-04 00:00:00.000000000 Z
12
+ date: 2019-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.7.6
145
+ rubygems_version: 2.6.14.1
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: A Docker jail for ruby code