docker-compose-api 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/docker-compose.rb +2 -2
- data/lib/docker-compose/models/compose_container.rb +14 -1
- data/lib/version.rb +1 -1
- data/spec/docker-compose/docker_compose_spec.rb +18 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6486732a5af8f446379a47c4381086d6c378d123
|
4
|
+
data.tar.gz: bf2845772899790686e19dd67ded50c3dcfad3ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 945430282e47ebba4183b49e84b05de55a645e1660caf91d2def11daf7bcec59297b849140389840a4e7a458e501d95f3983cf9d33d552fe38cdc89616096286
|
7
|
+
data.tar.gz: 24bf2267a1bd1353ce959345f47f4ceda4eec5b5ad9e7f06ef96b1edb27af6e1c5fcadb0814cef05250e6c96813804f5bfa17fc56e2153f6b85fd6eb4ddef15d
|
data/lib/docker-compose.rb
CHANGED
@@ -55,7 +55,7 @@ module DockerCompose
|
|
55
55
|
def self.load_running_containers(compose)
|
56
56
|
Docker::Container
|
57
57
|
.all(all: true)
|
58
|
-
.select {|c| c.info['
|
58
|
+
.select {|c| c.info['Labels']['com.docker.compose.project'] == ComposeUtils.dir_name }
|
59
59
|
.each do |container|
|
60
60
|
compose.add_container(load_running_container(container))
|
61
61
|
end
|
@@ -64,7 +64,7 @@ module DockerCompose
|
|
64
64
|
def self.create_container(attributes)
|
65
65
|
ComposeContainer.new({
|
66
66
|
label: attributes[0],
|
67
|
-
|
67
|
+
full_name: attributes[1]['container_name'],
|
68
68
|
image: attributes[1]['image'],
|
69
69
|
build: attributes[1]['build'],
|
70
70
|
links: attributes[1]['links'],
|
@@ -19,7 +19,9 @@ class ComposeContainer
|
|
19
19
|
command: ComposeUtils.format_command(hash_attributes[:command]),
|
20
20
|
environment: prepare_environment(hash_attributes[:environment]),
|
21
21
|
labels: prepare_labels(hash_attributes[:labels])
|
22
|
-
}.reject{ |key, value| value.nil? }
|
22
|
+
}.reject { |key, value| value.nil? }
|
23
|
+
|
24
|
+
prepare_compose_labels
|
23
25
|
|
24
26
|
# Docker client variables
|
25
27
|
@internal_image = nil
|
@@ -182,6 +184,17 @@ class ComposeContainer
|
|
182
184
|
Hash[labels.map { |label| label.split('=') }]
|
183
185
|
end
|
184
186
|
|
187
|
+
#
|
188
|
+
# Adds internal docker-compose labels
|
189
|
+
#
|
190
|
+
def prepare_compose_labels
|
191
|
+
@attributes[:labels] = {} unless @attributes[:labels].is_a?(Hash)
|
192
|
+
|
193
|
+
@attributes[:labels]['com.docker.compose.project'] = ComposeUtils.dir_name
|
194
|
+
@attributes[:labels]['com.docker.compose.service'] = @attributes[:label]
|
195
|
+
@attributes[:labels]['com.docker.compose.oneoff'] = 'False'
|
196
|
+
end
|
197
|
+
|
185
198
|
#
|
186
199
|
# Check if a given image already exists in host
|
187
200
|
#
|
data/lib/version.rb
CHANGED
@@ -244,7 +244,7 @@ describe DockerCompose do
|
|
244
244
|
container.start
|
245
245
|
|
246
246
|
env = container.stats['Config']['Labels']
|
247
|
-
expect(env
|
247
|
+
expect(env['com.example.foo']).to eq('bar')
|
248
248
|
|
249
249
|
# Stop container
|
250
250
|
container.stop
|
@@ -257,20 +257,33 @@ describe DockerCompose do
|
|
257
257
|
container.start
|
258
258
|
|
259
259
|
env = container.stats['Config']['Labels']
|
260
|
-
expect(env
|
260
|
+
expect(env['com.example.foo']).to eq('bar')
|
261
261
|
|
262
262
|
# Stop container
|
263
263
|
container.stop
|
264
264
|
end
|
265
265
|
|
266
266
|
it 'should assing given name to container' do
|
267
|
+
container = @compose.get_containers_by(label: 'busybox2').first
|
268
|
+
|
269
|
+
# Start container
|
270
|
+
container.start
|
271
|
+
|
272
|
+
container_name = container.stats['Name']
|
273
|
+
expect(container_name).to match(/\/#{ComposeUtils.dir_name}_busybox2_\d+/)
|
274
|
+
|
275
|
+
# Stop container
|
276
|
+
container.stop
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'should assing given container_name to container' do
|
267
280
|
container = @compose.get_containers_by(label: 'busybox1').first
|
268
281
|
|
269
282
|
# Start container
|
270
283
|
container.start
|
271
284
|
|
272
285
|
container_name = container.stats['Name']
|
273
|
-
expect(container_name).to
|
286
|
+
expect(container_name).to eq('/busybox-container')
|
274
287
|
|
275
288
|
# Stop container
|
276
289
|
container.stop
|
@@ -292,7 +305,8 @@ describe DockerCompose do
|
|
292
305
|
it 'should filter containers by its attributes' do
|
293
306
|
expect(@compose.get_containers_by(label: 'busybox2')).to eq([@compose.containers['busybox2']])
|
294
307
|
expect(@compose.get_containers_by(name: @compose.containers['busybox1'].attributes[:name])).to eq([@compose.containers['busybox1']])
|
295
|
-
expect(@compose.get_containers_by_given_name('
|
308
|
+
expect(@compose.get_containers_by_given_name('busybox2')).to eq([@compose.containers['busybox2']])
|
309
|
+
expect(@compose.get_containers_by(name: 'busybox-container')).to eq([@compose.containers['busybox1']])
|
296
310
|
expect(@compose.get_containers_by(image: 'busybox:latest')).to eq([
|
297
311
|
@compose.containers['busybox1'],
|
298
312
|
@compose.containers['busybox2'],
|