docker-api 1.27.0 → 1.28.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
  SHA1:
3
- metadata.gz: a402451b60cf3ee27d968b6c406b763ba02fd064
4
- data.tar.gz: 239c7b7261f471873819ade511325c785e632d0f
3
+ metadata.gz: 208227d2b48722c6c994b7182065a13ee1e478ce
4
+ data.tar.gz: 7fe1de106942c93a80884c0b5ca65a06bf237e81
5
5
  SHA512:
6
- metadata.gz: 68228f7e53d244b754ce9c26c3a2e412c4162595ae4fc069afea00aa5b89a499f205bcd2be5e055a274ce6e1f5ef2a9188dec364c2086505817176c4bb66a737
7
- data.tar.gz: 128d69692f073e103aeef72af0743d5ab3db5020b770242f8df4964da3b0ec6c88c70e587e25822e0a66c80cd3c6bebfdf05f7fa90d501850960b71272c29df9
6
+ metadata.gz: 8420bbc610fa614cd590c9ff449a98e237c9bdaa20c91b03954c2c9d797849cb48f97e2048ee4589b095f0448fe9ab9e46685dcbe884d232cb3c9339313c47e3
7
+ data.tar.gz: 64af52f1ed2c4a9b25c69759c06d77745e8ce7843db8675247b6225318b809754b4c336f50ebae01fbfcd20cc3b4adde22042c2eeb9fb96e7a03aba85a7b2a8d
data/README.md CHANGED
@@ -108,7 +108,7 @@ require 'docker'
108
108
  Docker.version
109
109
  # => { 'Version' => '0.5.2', 'GoVersion' => 'go1.1' }
110
110
 
111
- # docker command for reference: docker info
111
+ # docker command for reference: docker info
112
112
  Docker.info
113
113
  # => { "Debug" => false, "Containers" => 187, "Images" => 196, "NFd" => 10, "NGoroutines" => 9, "MemoryLimit" => true }
114
114
 
@@ -245,6 +245,16 @@ Docker::Image.get('df4f1bdecf40')
245
245
  Docker::Image.exist?('ef723dcdac09')
246
246
  # => true
247
247
 
248
+ # Load an image from the file system
249
+ Docker::Image.load('./my-image.tar')
250
+ # => ""
251
+
252
+ # An IO object may also be specified for loading
253
+ File.open('./my-image.tar', 'rb') do |file|
254
+ Docker::Image.load(file)
255
+ end
256
+ # => ""
257
+
248
258
  # Export multiple images to a single tarball
249
259
  # docker command for reference: docker save my_image1 my_image2:not_latest > my_export.tar
250
260
  names = %w( my_image1 my_image2:not_latest )
@@ -171,14 +171,14 @@ class Docker::Image
171
171
  # Load a tar Image
172
172
  def load(tar, opts = {}, conn = Docker.connection, creds = nil, &block)
173
173
  headers = build_headers(creds)
174
+ io = tar.is_a?(String) ? File.open(tar, 'rb') : tar
174
175
  body = ""
175
- f = File.open(tar,'rb')
176
176
  conn.post(
177
177
  '/images/load',
178
178
  opts,
179
179
  :headers => headers,
180
180
  :response_block => response_block(body, &block)
181
- ) { f.read(Excon.defaults[:chunk_size]).to_s }
181
+ ) { io.read(Excon.defaults[:chunk_size]).to_s }
182
182
  end
183
183
 
184
184
  # Check if an image exists.
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.27.0'
3
+ VERSION = '1.28.0'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.16'
@@ -280,17 +280,6 @@ describe Docker::Image do
280
280
  end
281
281
  end
282
282
 
283
- describe '#load' do
284
- include_context "local paths"
285
- let(:file) { File.join(project_dir, 'spec', 'fixtures', 'load.tar') }
286
- context 'test image upload' do
287
- it 'load tianon/true image' do
288
- result = Docker::Image.load(file)
289
- expect(result).to eq("")
290
- end
291
- end
292
- end
293
-
294
283
  describe '#refresh!' do
295
284
  let(:image) { Docker::Image.create('fromImage' => 'debian:wheezy') }
296
285
 
@@ -312,6 +301,29 @@ describe Docker::Image do
312
301
  end
313
302
  end
314
303
 
304
+ describe '.load' do
305
+ include_context "local paths"
306
+ let(:file) { File.join(project_dir, 'spec', 'fixtures', 'load.tar') }
307
+
308
+ context 'when the argument is a String' do
309
+ it 'loads tianon/true image from the file system' do
310
+ result = Docker::Image.load(file)
311
+ expect(result).to eq("")
312
+ end
313
+ end
314
+
315
+ context 'when the argument is an IO' do
316
+ let(:io) { File.open(file) }
317
+
318
+ after { io.close }
319
+
320
+ it 'loads tinan/true image from the IO' do
321
+ result = Docker::Image.load(io)
322
+ expect(result).to eq("")
323
+ end
324
+ end
325
+ end
326
+
315
327
  describe '.create' do
316
328
  subject { described_class }
317
329
 
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.27.0
4
+ version: 1.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swipely, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon