docker-api 1.21.2 → 1.21.3

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: 465cef36deedd1a54ea562f74f85b2f268e6851a
4
- data.tar.gz: 1a786818a3a8b34680ea6ae056e6b37020a29da2
3
+ metadata.gz: 7f782a3d4812316b9a78a9c9850000409fcf2f58
4
+ data.tar.gz: 4d7aa0d552a978aefdb81bb9abd161a90b3a598b
5
5
  SHA512:
6
- metadata.gz: 89f9d252d33a66488c67670113c4ae6461c32ce014a3f81adc582224eaa02c1c3d839b6c3740bcb55ae6b871206ef5cd9852bf24acfd84bf97ee125a30d48a3c
7
- data.tar.gz: 1286dcbb395dc2e6b837a7f434bedcef62e6c3daf0f3698d248ca3236db19071430d9a8e8460dee9126cad269d5bdeffdce53b4483853d4bc39dd7f4ee7d1977
6
+ metadata.gz: ac799a15c88a4113554472df394449e71bd7ff935e65c2b2f5112ea8e8d0e1b65d2f5da1681b81985aa3dd98c4c211427a00ffd4c2805be2b07005f511f0ce45
7
+ data.tar.gz: c304cc3fc7ac0bc5970e3be2cf718ecb34540ff786a1f3e3196b374ae7566419ae361ba38c32106a5558c53b749ab35c420f1f0e46346ac7daf63771965d40d5
@@ -138,8 +138,8 @@ module Docker::Util
138
138
  next unless stat.file?
139
139
 
140
140
  unprefixed_file_name = prefixed_file_name[directory.length..-1]
141
- tar.add_file_simple(
142
- unprefixed_file_name, stat.mode, stat.size
141
+ add_file_to_tar(
142
+ tar, unprefixed_file_name, stat.mode, stat.size, stat.mtime
143
143
  ) do |tar_file|
144
144
  IO.copy_stream(File.open(prefixed_file_name, 'rb'), tar_file)
145
145
  end
@@ -147,6 +147,31 @@ module Docker::Util
147
147
  end
148
148
  end
149
149
 
150
+ def add_file_to_tar(tar, name, mode, size, mtime)
151
+ tar.check_closed
152
+
153
+ io = tar.instance_variable_get(:@io)
154
+
155
+ name, prefix = tar.split_name(name)
156
+
157
+ header = Gem::Package::TarHeader.new(:name => name, :mode => mode,
158
+ :size => size, :prefix => prefix,
159
+ :mtime => mtime).to_s
160
+
161
+ io.write header
162
+ os = Gem::Package::TarWriter::BoundedStream.new io, size
163
+
164
+ yield os if block_given?
165
+
166
+ min_padding = size - os.written
167
+ io.write("\0" * min_padding)
168
+
169
+ remainder = (512 - (size % 512)) % 512
170
+ io.write("\0" * remainder)
171
+
172
+ tar
173
+ end
174
+
150
175
  def create_temp_file
151
176
  tempfile_name = Dir::Tmpname.create('out') {}
152
177
  File.open(tempfile_name, 'wb+')
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.21.2'
3
+ VERSION = '1.21.3'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.16'
@@ -564,30 +564,37 @@ describe Docker::Image do
564
564
  Docker::Container.create('Image' => image.id,
565
565
  'Cmd' => %w[cat /Dockerfile])
566
566
  end
567
- let!(:output) {
568
- container.tap(&:start).streaming_logs(stdout: true)
569
- }
567
+ let(:output) { container.streaming_logs(stdout: true) }
568
+
570
569
  after(:each) do
571
- container.tap(&:wait).remove
572
570
  image.remove(:noprune => true)
573
571
  end
574
572
 
575
573
  context 'with no query parameters' do
576
574
  it 'builds the image', :vcr do
577
- container.wait
575
+ container.tap(&:wait).start
578
576
  expect(output).to eq(docker_file.read)
579
577
  end
578
+
579
+ after do
580
+ container.remove
581
+ end
580
582
  end
581
583
 
582
584
  context 'with specifying a repo in the query parameters' do
583
585
  let(:opts) { { "t" => "#{ENV['DOCKER_API_USER']}/debian:from_dir" } }
584
586
  it 'builds the image and tags it', :vcr do
587
+ container.tap(&:wait).start
585
588
  expect(output).to eq(docker_file.read)
586
589
  image.refresh!
587
590
  expect(image.info["RepoTags"]).to eq(
588
591
  ["#{ENV['DOCKER_API_USER']}/debian:from_dir"]
589
592
  )
590
593
  end
594
+
595
+ after do
596
+ container.remove
597
+ end
591
598
  end
592
599
 
593
600
  context 'with a block capturing build output' do
@@ -598,6 +605,21 @@ describe Docker::Image do
598
605
  image # Create the image variable, which is lazy-loaded by Rspec
599
606
  expect(build_output).to match(/Step 0 : FROM debian:wheezy/)
600
607
  end
608
+
609
+ context 'uses a cached version the second time' do
610
+ let(:build_output_two) { "" }
611
+ let(:block_two) { Proc.new { |chunk| build_output_two << chunk } }
612
+ let(:image_two) { subject.build_from_dir(dir, opts, &block_two) }
613
+
614
+ it 'calls the block and passes build output', :vcr do
615
+ image # Create the image variable, which is lazy-loaded by Rspec
616
+ expect(build_output).to match(/Step 0 : FROM debian:wheezy/)
617
+ expect(build_output).to_not match(/Using cache/)
618
+
619
+ image_two # Create the image_two variable, which is lazy-loaded by Rspec
620
+ expect(build_output_two).to match(/Using cache/)
621
+ end
622
+ end
601
623
  end
602
624
 
603
625
  context 'with credentials passed' do
@@ -4,7 +4,7 @@ require 'docker'
4
4
 
5
5
  VCR.configure do |c|
6
6
  c.allow_http_connections_when_no_cassette = false
7
- c.filter_sensitive_data('<DOCKER_HOST>') { Docker.url.sub(/tcp\:/, 'https:') }
7
+ c.filter_sensitive_data('<DOCKER_HOST>') { Docker.url }
8
8
  c.filter_sensitive_data('<USERNAME>') { ENV['DOCKER_API_USER'] }
9
9
  c.filter_sensitive_data('<PASSWORD>') { ENV['DOCKER_API_PASS'] }
10
10
  c.filter_sensitive_data('<EMAIL>') { ENV['DOCKER_API_EMAIL'] }
@@ -0,0 +1,96 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<DOCKER_HOST>/v1.16/build"
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Swipely/Docker-API 1.21.0
12
+ Content-Type:
13
+ - application/tar
14
+ Transfer-Encoding:
15
+ - chunked
16
+ X-Registry-Config:
17
+ - eyJjb25maWdzIjp7IiI6eyJ1c2VybmFtZSI6IiIsInBhc3N3b3JkIjoiIiwiZW1haWwiOiIifX19
18
+ response:
19
+ status:
20
+ code: 200
21
+ message:
22
+ headers:
23
+ Content-Type:
24
+ - application/json
25
+ Date:
26
+ - Fri, 03 Apr 2015 20:19:34 GMT
27
+ body:
28
+ encoding: UTF-8
29
+ string: "{\"stream\":\"Step 0 : FROM debian:wheezy\\n\"}\r\n{\"stream\":\" ---\\u003e
30
+ 1265e16d0c28\\n\"}\r\n{\"stream\":\"Step 1 : ADD . /\\n\"}\r\n{\"stream\":\"
31
+ ---\\u003e 1df5fb96c8b6\\n\"}\r\n{\"stream\":\"Removing intermediate container
32
+ 31c097a22066\\n\"}\r\n{\"stream\":\"Successfully built 1df5fb96c8b6\\n\"}\r\n"
33
+ http_version:
34
+ recorded_at: Wed, 08 Apr 2015 15:07:59 GMT
35
+ - request:
36
+ method: post
37
+ uri: "<DOCKER_HOST>/v1.16/build"
38
+ body:
39
+ encoding: US-ASCII
40
+ string: ''
41
+ headers:
42
+ User-Agent:
43
+ - Swipely/Docker-API 1.21.0
44
+ Content-Type:
45
+ - application/tar
46
+ Transfer-Encoding:
47
+ - chunked
48
+ X-Registry-Config:
49
+ - eyJjb25maWdzIjp7IiI6eyJ1c2VybmFtZSI6IiIsInBhc3N3b3JkIjoiIiwiZW1haWwiOiIifX19
50
+ response:
51
+ status:
52
+ code: 200
53
+ message:
54
+ headers:
55
+ Content-Type:
56
+ - application/json
57
+ Date:
58
+ - Fri, 03 Apr 2015 20:19:36 GMT
59
+ body:
60
+ encoding: UTF-8
61
+ string: "{\"stream\":\"Step 0 : FROM debian:wheezy\\n\"}\r\n{\"stream\":\" ---\\u003e
62
+ 1265e16d0c28\\n\"}\r\n{\"stream\":\"Step 1 : ADD . /\\n\"}\r\n{\"stream\":\"
63
+ ---\\u003e Using cache\\n\"}\r\n{\"stream\":\" ---\\u003e 1df5fb96c8b6\\n\"}\r\n{\"stream\":\"Successfully
64
+ built 1df5fb96c8b6\\n\"}\r\n"
65
+ http_version:
66
+ recorded_at: Wed, 08 Apr 2015 15:07:59 GMT
67
+ - request:
68
+ method: delete
69
+ uri: "<DOCKER_HOST>/v1.16/images/1df5fb96c8b6?noprune=true"
70
+ body:
71
+ encoding: US-ASCII
72
+ string: ''
73
+ headers:
74
+ User-Agent:
75
+ - Swipely/Docker-API 1.21.0
76
+ Content-Type:
77
+ - text/plain
78
+ response:
79
+ status:
80
+ code: 200
81
+ message:
82
+ headers:
83
+ Content-Type:
84
+ - application/json
85
+ Date:
86
+ - Fri, 03 Apr 2015 20:19:37 GMT
87
+ Content-Length:
88
+ - '81'
89
+ body:
90
+ encoding: UTF-8
91
+ string: |-
92
+ [{"Deleted":"1df5fb96c8b6f0f21cf5898ad17867b80f0b58d2db5859fcc997dfde7d903b56"}
93
+ ]
94
+ http_version:
95
+ recorded_at: Wed, 08 Apr 2015 15:07:59 GMT
96
+ recorded_with: VCR 2.9.2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.2
4
+ version: 1.21.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swipely, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -262,6 +262,7 @@ files:
262
262
  - spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/without_query_parameters/builds_an_image.yml
263
263
  - spec/vcr/Docker_Image/_build/with_an_invalid_Dockerfile/throws_a_UnexpectedResponseError.yml
264
264
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_a_block_capturing_build_output/calls_the_block_and_passes_build_output.yml
265
+ - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_a_block_capturing_build_output/uses_a_cached_version_the_second_time/calls_the_block_and_passes_build_output.yml
265
266
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_credentials_passed/sends_X-Registry-Config_header.yml
266
267
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_no_query_parameters/builds_the_image.yml
267
268
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_specifying_a_repo_in_the_query_parameters/builds_the_image_and_tags_it.yml
@@ -387,6 +388,7 @@ test_files:
387
388
  - spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/without_query_parameters/builds_an_image.yml
388
389
  - spec/vcr/Docker_Image/_build/with_an_invalid_Dockerfile/throws_a_UnexpectedResponseError.yml
389
390
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_a_block_capturing_build_output/calls_the_block_and_passes_build_output.yml
391
+ - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_a_block_capturing_build_output/uses_a_cached_version_the_second_time/calls_the_block_and_passes_build_output.yml
390
392
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_credentials_passed/sends_X-Registry-Config_header.yml
391
393
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_no_query_parameters/builds_the_image.yml
392
394
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_specifying_a_repo_in_the_query_parameters/builds_the_image_and_tags_it.yml