moby-derp 0.3.3 → 0.4.0

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
2
  SHA256:
3
- metadata.gz: 443db141ccca9522f7fe188a5fb5b0ed972197eb4de18e899ad275adaf16689c
4
- data.tar.gz: 75c10f4b97000efccd2ba4f0bda78b8a5fa44a77c6e1e37262a8744324242b88
3
+ metadata.gz: 31c2c89cac1b196c48dc2c2183367d61578b1e4e1bae1ff7d698dd7ef6c23cb5
4
+ data.tar.gz: c7b83663a971a01f3e8b5e8a5420b12b6192d207107ce1cd3047539644051f3e
5
5
  SHA512:
6
- metadata.gz: f75ffe9184bdcc0949ee6030b04927e7821c4bfa4a9a7d3ede99947f24f05580d58e28edd9efc253fa420c733a1d64e8a3cc85bc3df900e6479d9de35a8c39f6
7
- data.tar.gz: dcc3c3a0ac2ed25d321b15118a876f3b40288ba028736324ee61b5783615da74d941532c000fd01795ecdf316e8c56a95b5a18332dd9a9e1c180224b87eeba4a
6
+ metadata.gz: 34c40eb8d1d8cfa668a3048c6a8ceaf231c4fae6a607d389bf073d3a3874a74a10a31e728c0c322476a154c9c425fd92869d0fb5849707c1dee2b4c0970f15af
7
+ data.tar.gz: 01d15f3f197b48fe5748f27718a8e8c7035ff0713113742bf1ae7a43a480197ab7a97559e4ae19fbec8ca5711d22ebd38f02865194e9ce73a817b11a0899bf9a
@@ -71,6 +71,7 @@ module MobyDerp
71
71
  }
72
72
  }
73
73
  end
74
+ params["ExposedPorts"] = Hash[@pod.expose.map { |ex| [ex, {}] }]
74
75
  else
75
76
  params["HostConfig"] = {
76
77
  "NetworkMode" => "container:#{@pod.root_container_id}",
@@ -3,6 +3,7 @@ require_relative "./error"
3
3
  require_relative "./mount"
4
4
 
5
5
  require "docker-api"
6
+ require "shellwords"
6
7
 
7
8
  module MobyDerp
8
9
  class ContainerConfig
@@ -66,7 +67,10 @@ module MobyDerp
66
67
  def validate_command
67
68
  case @command
68
69
  when String
69
- true
70
+ # Despite the Docker Engine API spec saying you can pass a string,
71
+ # if you do it doesn't get parsed into arguments... so that's pretty
72
+ # fucking useless.
73
+ @command = Shellwords.split(@command)
70
74
  when Array
71
75
  unless @command.all? { |c| String === c }
72
76
  raise ConfigurationError, "all elements of the command array must be strings"
data/lib/moby_derp/pod.rb CHANGED
@@ -68,6 +68,10 @@ module MobyDerp
68
68
  @config.hostname
69
69
  end
70
70
 
71
+ def expose
72
+ @config.expose
73
+ end
74
+
71
75
  private
72
76
 
73
77
  def root_container
@@ -21,8 +21,8 @@ module MobyDerp
21
21
  :publish,
22
22
  :publish_all,
23
23
  :mount_root,
24
- :system_config,
25
- :logger
24
+ :system_config,
25
+ :logger
26
26
 
27
27
  def initialize(filename, system_config)
28
28
  @logger = system_config.logger
@@ -181,18 +181,23 @@ module MobyDerp
181
181
  "expose must be an array"
182
182
  end
183
183
 
184
- @expose.map!(&:to_s)
185
-
186
- @expose.each do |e|
184
+ @expose.map! do |e|
185
+ e = e.to_s
187
186
  unless e.is_a?(String) && e =~ %r{\A\d+(/(tcp|udp))?\z}
188
187
  raise ConfigurationError,
189
188
  "exposed ports must be integers, with an optional protocol specifier (got #{e.inspect})"
190
189
  end
191
190
 
191
+ if $1.nil?
192
+ e += "/tcp"
193
+ end
194
+
192
195
  if e.to_i < 1 || e.to_i > 65535
193
196
  raise ConfigurationError,
194
197
  "exposed port #{e} is out of range (expected 1-65535)"
195
198
  end
199
+
200
+ e
196
201
  end
197
202
  end
198
203
 
@@ -0,0 +1,28 @@
1
+ load test_helper
2
+
3
+ @test "Exposed ports" {
4
+ config_file <<-'EOF'
5
+ expose:
6
+ - 80
7
+ - "53/udp"
8
+ containers:
9
+ bob:
10
+ image: busybox:latest
11
+ command: sleep 600
12
+ common_labels:
13
+ moby-derp-smoke-test: ayup
14
+ EOF
15
+
16
+ run $MOBY_DERP_BIN $TEST_CONFIG_FILE
17
+
18
+ echo "status: $status"
19
+ echo "output: $output"
20
+
21
+ [ "$status" = "0" ]
22
+ container_running "mdst"
23
+ container_running "mdst.bob"
24
+
25
+ docker inspect mdst --format='{{.Config.ExposedPorts}}'
26
+ docker inspect mdst --format='{{.Config.ExposedPorts}}' | grep 'map.*53/udp:{}'
27
+ docker inspect mdst --format='{{.Config.ExposedPorts}}' | grep 'map.*80/tcp:{}'
28
+ }
@@ -23,7 +23,7 @@ EOF
23
23
  teardown() {
24
24
  for i in $(docker ps -a --format='{{.Names}}'); do
25
25
  if docker container inspect $i --format='{{.Config.Labels}}' | grep -q moby-derp-smoke-test; then
26
- docker rm -f $i
26
+ docker rm -f $i >/dev/null
27
27
  fi
28
28
  done
29
29
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moby-derp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-04 00:00:00.000000000 Z
11
+ date: 2019-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -220,6 +220,7 @@ files:
220
220
  - lib/moby_derp/pod_config.rb
221
221
  - lib/moby_derp/system_config.rb
222
222
  - moby-derp.gemspec
223
+ - smoke_tests/exposed.bats
223
224
  - smoke_tests/minimal.bats
224
225
  - smoke_tests/no_file.bats
225
226
  - smoke_tests/test_helper.bash