docker-compose 0.5.0 → 0.5.1
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/lib/docker/compose/mapper.rb +29 -17
- data/lib/docker/compose/session.rb +9 -0
- data/lib/docker/compose/version.rb +1 -1
- 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: a85e6cd467f9c5c4a6704724d9429a4f681d065a
|
4
|
+
data.tar.gz: a5f85af19b15c215b68a01e7004bf0c0cb05587e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a9143db8626ea989d500c29a802c79b84c50ebd66674daf9bfff474f413353a9d3203bd1860d5dce3dbefa2301fc44521db597fd56b4cdf95d9ff295d11be57
|
7
|
+
data.tar.gz: f2f68bd762d659926ec4880423db394e75ef03ea72f7ee0cf7af65e06639be902f0f0d9819128f64d6dc8e4d56d06b5ceb05795ed3e800ac1383f23b3939947d
|
@@ -20,7 +20,19 @@ module Docker::Compose
|
|
20
20
|
# @param [NetInfo] net_info
|
21
21
|
# @yield yields with each substituted (key, value) pair
|
22
22
|
def self.map(env, strict:true, session:Session.new, net_info:NetInfo.new)
|
23
|
-
|
23
|
+
# TODO: encapsulate this trickiness better ... inside NetInfo perhaps?
|
24
|
+
docker_host = ENV['DOCKER_HOST']
|
25
|
+
if docker_host.nil? || docker_host =~ /^(\/|unix|file)/
|
26
|
+
# If DOCKER_HOST is blank, or pointing to a local socket, then we
|
27
|
+
# can trust the address information returned by `docker-compose port`.
|
28
|
+
override_host = nil
|
29
|
+
else
|
30
|
+
# If DOCKER_HOST is present, assume that containers have bound to
|
31
|
+
# whatever IP we reach it at; don't fall victim to dirty NAT lies!
|
32
|
+
override_host = net_info.docker_routable_ip
|
33
|
+
end
|
34
|
+
|
35
|
+
mapper = self.new(session, override_host, strict:strict)
|
24
36
|
env.each_pair do |k, v|
|
25
37
|
begin
|
26
38
|
v = mapper.map(v)
|
@@ -33,15 +45,14 @@ module Docker::Compose
|
|
33
45
|
|
34
46
|
# Create an instance of Mapper
|
35
47
|
# @param [Docker::Compose::Session] session
|
36
|
-
# @param [String]
|
37
|
-
#
|
38
|
-
# IP if you are using a non-clustered Docker environment)
|
48
|
+
# @param [String] override_host forcible address or DNS hostname to use;
|
49
|
+
# leave nil to trust docker-compose output.
|
39
50
|
# @param [Boolean] strict if true, raise BadSubstitution when unrecognized
|
40
51
|
# syntax is passed to #map; if false, simply return unrecognized
|
41
52
|
# values without substituting anything
|
42
|
-
def initialize(session,
|
53
|
+
def initialize(session, override_host=nil, strict:true)
|
43
54
|
@session = session
|
44
|
-
@
|
55
|
+
@override_host = override_host
|
45
56
|
@strict = strict
|
46
57
|
end
|
47
58
|
|
@@ -81,10 +92,12 @@ module Docker::Compose
|
|
81
92
|
# "service not running" case and the "container port not published" case!
|
82
93
|
#
|
83
94
|
# @raise [NoService] if service is not up or does not publish port
|
84
|
-
# @return [
|
85
|
-
def
|
86
|
-
result = @session.port(service, port)
|
87
|
-
|
95
|
+
# @return [Array] (String, Integer) pair of host address and port number
|
96
|
+
def host_and_port(service, port)
|
97
|
+
result = @session.port(service, port).chomp
|
98
|
+
host, port = result.split(':')
|
99
|
+
host = @override_host if @override_host
|
100
|
+
[host, Integer(port)]
|
88
101
|
rescue RuntimeError
|
89
102
|
raise NoService, "Service '#{service}' not running, or does not publish port '#{port}'"
|
90
103
|
end
|
@@ -99,27 +112,26 @@ module Docker::Compose
|
|
99
112
|
|
100
113
|
if uri && uri.scheme && uri.host
|
101
114
|
# absolute URI with scheme, authority, etc
|
102
|
-
uri.port =
|
103
|
-
uri.host = @docker_host
|
115
|
+
uri.host, uri.port = host_and_port(uri.host, uri.port)
|
104
116
|
return uri.to_s
|
105
117
|
elsif pair.size == 2
|
106
118
|
# "host:port" pair; three sub-cases...
|
107
119
|
if pair.first =~ ELIDED
|
108
120
|
# output only the port
|
109
121
|
service = pair.first.gsub(REMOVE_ELIDED, '')
|
110
|
-
port =
|
122
|
+
_, port = host_and_port(service, pair.last)
|
111
123
|
return port.to_s
|
112
124
|
elsif pair.last =~ ELIDED
|
113
125
|
# output only the hostname; resolve the port anyway to ensure that
|
114
126
|
# the service is running.
|
115
127
|
service = pair.first
|
116
128
|
port = pair.last.gsub(REMOVE_ELIDED, '')
|
117
|
-
|
118
|
-
return
|
129
|
+
host, _ = host_and_port(service, port)
|
130
|
+
return host
|
119
131
|
else
|
120
132
|
# output port:hostname pair
|
121
|
-
port =
|
122
|
-
return "#{
|
133
|
+
host, port = host_and_port(pair.first, pair.last)
|
134
|
+
return "#{host}:#{port}"
|
123
135
|
end
|
124
136
|
elsif @strict
|
125
137
|
raise BadSubstitution, "Can't understand '#{value}'"
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'backticks'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module Docker::Compose
|
4
5
|
# A Ruby OOP interface to a docker-compose session. A session is bound to
|
@@ -22,6 +23,14 @@ module Docker::Compose
|
|
22
23
|
@file = file
|
23
24
|
end
|
24
25
|
|
26
|
+
# Validate docker-compose file and return it as Hash
|
27
|
+
# @return [Hash] the docker-compose config file
|
28
|
+
# @raise [Error] if command fails
|
29
|
+
def config(*args)
|
30
|
+
config = run!('config', *args)
|
31
|
+
YAML.load(config)
|
32
|
+
end
|
33
|
+
|
25
34
|
# Monitor the logs of one or more containers.
|
26
35
|
# @param [Array] services list of String service names to show logs for
|
27
36
|
# @return [true] always returns true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Spataro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backticks
|