docker-api 1.32.1 → 1.33.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: 5844d897e60f3ae8d2cbd363dc7fb56ef55eea87
4
- data.tar.gz: c4ed797a4159108d793011f8a6c947c699676100
3
+ metadata.gz: bb5ad2f5239058b4cbe3ceca06ac1455e659211d
4
+ data.tar.gz: dbeb560e89cacb6fecaf28a2370da23d44350da8
5
5
  SHA512:
6
- metadata.gz: b2ee7320b73738fcd948baf7e7833e697dadf721051f25d8e72a85a4b0cc9e35f8b2b26e917ca2854f01522e938878d0b8ec91a5e8aa52c2c02c9fa1c7407a67
7
- data.tar.gz: 523d65b0eefc2204d4fab0f707853acd50f31429007a5d0c499efe87615b97164e43ff008cbdee8a926b6959d1b012d3b6ab7436ed3a1e9c70aba95f56f5622d
6
+ metadata.gz: c2d333d808a12618046aeb497f11455db5053ae80bcb2fecd404ce94f7fa74f891b1df7f54c77d73a17478f835c721ce4bf9fb29f84553cc6ebd6e3e644866ac
7
+ data.tar.gz: 09f89ca78aef353c1727529649accc22604ad47668809e90e3a370095e93a178baba3299e96617f86ebfc0a3dda2cb172ce70eb198c2543d0c229750797158dd
data/README.md CHANGED
@@ -372,6 +372,12 @@ Docker::Container.create(
372
372
  }
373
373
  )
374
374
 
375
+ # To set container name pass `name` key to options
376
+ Docker::Container.create(
377
+ 'name' => 'my-new-container',
378
+ 'Image' => 'image-name'
379
+ )
380
+
375
381
  # Stores a file with the given content in the container
376
382
  container.store_file("/test", "Hello world")
377
383
 
@@ -14,7 +14,7 @@ require 'open-uri'
14
14
  require 'excon/middlewares/hijack'
15
15
  Excon.defaults[:middlewares].unshift Excon::Middleware::Hijack
16
16
 
17
- # The top-level module for this gem. It's purpose is to hold global
17
+ # The top-level module for this gem. Its purpose is to hold global
18
18
  # configuration variables that are used as defaults in other classes.
19
19
  module Docker
20
20
  attr_accessor :creds, :logger
@@ -158,9 +158,23 @@ class Docker::Container
158
158
  connection.get(path_for(:logs), opts)
159
159
  end
160
160
 
161
- # TODO: Implement Streaming stats
162
- def stats
163
- Docker::Util.parse_json(connection.get(path_for(:stats), {stream: 0}))
161
+ def stats(options = {})
162
+ if block_given?
163
+ options[:read_timeout] ||= 10
164
+ options[:idempotent] ||= false
165
+ parser = lambda do |chunk, remaining_bytes, total_bytes|
166
+ yield Docker::Util.parse_json(chunk)
167
+ end
168
+ begin
169
+ connection.get(path_for(:stats), nil, {response_block: parser}.merge(options))
170
+ rescue Docker::Error::TimeoutError
171
+ # If the container stops, the docker daemon will hold the connection
172
+ # open forever, but stop sending events.
173
+ # So this Timeout indicates the stream is over.
174
+ end
175
+ else
176
+ Docker::Util.parse_json(connection.get(path_for(:stats), {stream: 0}.merge(options)))
177
+ end
164
178
  end
165
179
 
166
180
  def rename(new_name)
@@ -317,7 +331,7 @@ class Docker::Container
317
331
 
318
332
  # Create a new Container.
319
333
  def self.create(opts = {}, conn = Docker.connection)
320
- name = opts.delete('name')
334
+ name = opts.delete('name') || opts.delete(:name)
321
335
  query = {}
322
336
  query['name'] = name if name
323
337
  resp = conn.post('/containers/create', query, :body => opts.to_json)
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.32.1'
3
+ VERSION = '1.33.0'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.16'
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.32.1
4
+ version: 1.33.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-10-04 00:00:00.000000000 Z
11
+ date: 2016-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon