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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aebb92beffc34f44faf26ba466f17b6c1d792856
4
- data.tar.gz: c0c71a9a9d249c3bdefdfaa2396adaf17a6b619c
3
+ metadata.gz: 6486732a5af8f446379a47c4381086d6c378d123
4
+ data.tar.gz: bf2845772899790686e19dd67ded50c3dcfad3ca
5
5
  SHA512:
6
- metadata.gz: 1f4646c618b28def5672fd2bf796ef6da3714bda760173d1f1c434140195f274c09dd70cdf1447f3e3206674ab3dac2e4539305a9bdc93cc149260edfa4f0558
7
- data.tar.gz: 9959ca0e28712b31b37d9b1ee5fe84c6736fe33939dc458c1bad3e898d790173f5c451871f479beb27077a331ddc943d592896816e0980b9582957306ddab399
6
+ metadata.gz: 945430282e47ebba4183b49e84b05de55a645e1660caf91d2def11daf7bcec59297b849140389840a4e7a458e501d95f3983cf9d33d552fe38cdc89616096286
7
+ data.tar.gz: 24bf2267a1bd1353ce959345f47f4ceda4eec5b5ad9e7f06ef96b1edb27af6e1c5fcadb0814cef05250e6c96813804f5bfa17fc56e2153f6b85fd6eb4ddef15d
@@ -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['Names'].last.match(/\A\/#{ComposeUtils.dir_name}\w*/) }
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
- name: attributes[1]['container_name'],
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
  #
@@ -1,5 +1,5 @@
1
1
  module DockerCompose
2
2
  def self.version
3
- "1.1.3"
3
+ "1.1.4"
4
4
  end
5
5
  end
@@ -244,7 +244,7 @@ describe DockerCompose do
244
244
  container.start
245
245
 
246
246
  env = container.stats['Config']['Labels']
247
- expect(env).to eq({ 'com.example.foo' => 'bar' })
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).to eq({ 'com.example.foo' => 'bar' })
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 match(/\/#{ComposeUtils.dir_name}_busybox-container_\d+/)
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('busybox-container')).to eq([@compose.containers['busybox1']])
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'],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-compose-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio S. Klein