docker-api 1.33.6 → 1.34.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: 5531d0312fee71792d5f38dcd31a12b6852d2245
4
- data.tar.gz: c077536fb349e32d0631ec9865a7e47cb8e54a18
3
+ metadata.gz: 9b1247193395e3bff8d8813de77e6b2ec7462b5a
4
+ data.tar.gz: d2eab94c0fc86823c3c2367bc2ac7fdcf9c439d1
5
5
  SHA512:
6
- metadata.gz: 0faf8023e582dd678958e593f0d83fb406e687a0e6ecbe570b4e2d9abc932ce79009935a84cffd4ba1b1c45b09943e67c206492d0ec873297a6c05c54a533c1a
7
- data.tar.gz: 919a70b572b5568c9d60990beb99a96624d259687c7686fd0093418871d35d738fa7bf572166c0ba5c80e3858ca22e4a2144a36de433157de5e589ad3d74f93c
6
+ metadata.gz: da393c71a9de916af0748b925eb6643d4a716701de07fbcb27349cbf5d6dad1a19757a503b6d94168bc7e7839641b8a23a3d6d2784b12fc1a1b1a0a670b6e51d
7
+ data.tar.gz: 593f911817f00d6c8ea3da3176549dad5a487c047c2608ddfe05297187c0db3876a88944ff7773cf364b3e39e9f1b4b67044031cf0b6447d44229a17b3e929a8
data/lib/docker.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'cgi'
2
- require 'json'
2
+ require 'multi_json'
3
3
  require 'excon'
4
4
  require 'tempfile'
5
5
  require 'base64'
@@ -121,8 +121,8 @@ module Docker
121
121
 
122
122
  # Login to the Docker registry.
123
123
  def authenticate!(options = {}, connection = self.connection)
124
- creds = options.to_json
125
- connection.post('/auth', {}, :body => creds)
124
+ creds = MultiJson.dump(options)
125
+ connection.post('/auth', {}, body: creds)
126
126
  @creds = creds
127
127
  true
128
128
  rescue Docker::Error::ServerError, Docker::Error::UnauthorizedError
@@ -135,10 +135,10 @@ class Docker::Container
135
135
  # Based on the link, the config passed as run, needs to be passed as the
136
136
  # body of the post so capture it, remove from the options, and pass it via
137
137
  # the post body
138
- config = options.delete('run')
139
- hash = Docker::Util.parse_json(connection.post('/commit',
140
- options,
141
- :body => config.to_json))
138
+ config = MultiJson.dump(options.delete('run'))
139
+ hash = Docker::Util.parse_json(
140
+ connection.post('/commit', options, body: config)
141
+ )
142
142
  Docker::Image.send(:new, self.connection, hash)
143
143
  end
144
144
 
@@ -185,7 +185,7 @@ class Docker::Container
185
185
  end
186
186
 
187
187
  def update(opts)
188
- connection.post(path_for(:update), {}, body: opts.to_json)
188
+ connection.post(path_for(:update), {}, body: MultiJson.dump(opts))
189
189
  end
190
190
 
191
191
  def streaming_logs(opts = {}, &block)
@@ -199,7 +199,7 @@ class Docker::Container
199
199
  end
200
200
 
201
201
  def start!(opts = {})
202
- connection.post(path_for(:start), {}, :body => opts.to_json)
202
+ connection.post(path_for(:start), {}, body: MultiJson.dump(opts))
203
203
  self
204
204
  end
205
205
 
@@ -225,7 +225,7 @@ class Docker::Container
225
225
  timeout = opts.delete('timeout')
226
226
  query = {}
227
227
  request_options = {
228
- :body => opts.to_json
228
+ :body => MultiJson.dump(opts)
229
229
  }
230
230
  if timeout
231
231
  query['t'] = timeout
@@ -267,9 +267,11 @@ class Docker::Container
267
267
  end
268
268
 
269
269
  def copy(path, &block)
270
- connection.post(path_for(:copy), {},
271
- :body => { "Resource" => path }.to_json,
272
- :response_block => block
270
+ connection.post(
271
+ path_for(:copy),
272
+ {},
273
+ body: MultiJson.dump('Resource' => path),
274
+ response_block: block
273
275
  )
274
276
  self
275
277
  end
@@ -332,10 +334,9 @@ class Docker::Container
332
334
 
333
335
  # Create a new Container.
334
336
  def self.create(opts = {}, conn = Docker.connection)
335
- name = opts.delete('name') || opts.delete(:name)
336
- query = {}
337
- query['name'] = name if name
338
- resp = conn.post('/containers/create', query, :body => opts.to_json)
337
+ query = opts.select {|key| ['name', :name].include?(key) }
338
+ clean_opts = opts.reject {|key| ['name', :name].include?(key) }
339
+ resp = conn.post('/containers/create', query, :body => MultiJson.dump(clean_opts))
339
340
  hash = Docker::Util.parse_json(resp) || {}
340
341
  new(conn, hash)
341
342
  end
@@ -353,6 +354,12 @@ class Docker::Container
353
354
  hashes.map { |hash| new(conn, hash) }
354
355
  end
355
356
 
357
+ # Prune images
358
+ def self.prune(conn = Docker.connection)
359
+ conn.post("/containers/prune", {})
360
+ nil
361
+ end
362
+
356
363
  # Convenience method to return the path for a particular resource.
357
364
  def path_for(resource)
358
365
  "/containers/#{self.id}/#{resource}"
data/lib/docker/exec.rb CHANGED
@@ -20,7 +20,7 @@ class Docker::Exec
20
20
  def self.create(options = {}, conn = Docker.connection)
21
21
  container = options.delete('Container')
22
22
  resp = conn.post("/containers/#{container}/exec", {},
23
- :body => options.to_json)
23
+ body: MultiJson.dump(options))
24
24
  hash = Docker::Util.parse_json(resp) || {}
25
25
  new(conn, hash)
26
26
  end
@@ -51,11 +51,11 @@ class Docker::Exec
51
51
  read_timeout = options[:wait]
52
52
 
53
53
  # Create API Request Body
54
- body = {
55
- "Tty" => tty,
56
- "Detach" => detached
57
- }
58
- excon_params = { :body => body.to_json }
54
+ body = MultiJson.dump(
55
+ 'Tty' => tty,
56
+ 'Detach' => detached
57
+ )
58
+ excon_params = { body: body }
59
59
 
60
60
  msgs = Docker::Messages.new
61
61
  unless detached
data/lib/docker/image.rb CHANGED
@@ -108,7 +108,7 @@ class Docker::Image
108
108
 
109
109
  # Create a new Image.
110
110
  def create(opts = {}, creds = nil, conn = Docker.connection, &block)
111
- credentials = creds.nil? ? Docker.creds : creds.to_json
111
+ credentials = creds.nil? ? Docker.creds : MultiJson.dump(creds)
112
112
  headers = credentials && Docker::Util.build_auth_header(credentials) || {}
113
113
  body = ''
114
114
  conn.post(
@@ -137,6 +137,12 @@ class Docker::Image
137
137
  end
138
138
  alias_method :delete, :remove
139
139
 
140
+ # Prune images
141
+ def prune(conn = Docker.connection)
142
+ conn.post("/images/prune", {})
143
+ end
144
+
145
+
140
146
  # Save the raw binary representation or one or more Docker images
141
147
  #
142
148
  # @param names [String, Array#String] The image(s) you wish to save
@@ -3,17 +3,17 @@ class Docker::Network
3
3
  include Docker::Base
4
4
 
5
5
  def connect(container, opts = {}, body_opts = {})
6
+ body = MultiJson.dump({ container: container }.merge(body_opts))
6
7
  Docker::Util.parse_json(
7
- connection.post(path_for('connect'), opts,
8
- body: { container: container }.merge(body_opts).to_json)
8
+ connection.post(path_for('connect'), opts, body: body)
9
9
  )
10
10
  reload
11
11
  end
12
12
 
13
13
  def disconnect(container, opts = {})
14
+ body = MultiJson.dump(container: container)
14
15
  Docker::Util.parse_json(
15
- connection.post(path_for('disconnect'), opts,
16
- body: { container: container }.to_json)
16
+ connection.post(path_for('disconnect'), opts, body: body)
17
17
  )
18
18
  reload
19
19
  end
@@ -41,12 +41,11 @@ class Docker::Network
41
41
 
42
42
  class << self
43
43
  def create(name, opts = {}, conn = Docker.connection)
44
- default_opts = {
44
+ default_opts = MultiJson.dump({
45
45
  'Name' => name,
46
46
  'CheckDuplicate' => true
47
- }
48
- resp = conn.post('/networks/create', {},
49
- body: default_opts.merge(opts).to_json)
47
+ }.merge(opts))
48
+ resp = conn.post('/networks/create', {}, body: default_opts)
50
49
  response_hash = Docker::Util.parse_json(resp) || {}
51
50
  get(response_hash['Id'], {}, conn) || {}
52
51
  end
@@ -67,6 +66,11 @@ class Docker::Network
67
66
  nil
68
67
  end
69
68
  alias_method :delete, :remove
69
+
70
+ def prune(conn = Docker.connection)
71
+ conn.post("/networks/prune", {})
72
+ nil
73
+ end
70
74
  end
71
75
 
72
76
  # Convenience method to return the path for a particular resource.
data/lib/docker/util.rb CHANGED
@@ -102,8 +102,8 @@ module Docker::Util
102
102
  end
103
103
 
104
104
  def parse_json(body)
105
- JSON.parse(body) unless body.nil? || body.empty? || (body == 'null')
106
- rescue JSON::ParserError => ex
105
+ MultiJson.load(body) unless body.nil? || body.empty? || (body == 'null')
106
+ rescue MultiJson::ParseError => ex
107
107
  raise UnexpectedResponseError, ex.message
108
108
  end
109
109
 
@@ -232,7 +232,7 @@ module Docker::Util
232
232
  end
233
233
 
234
234
  def build_auth_header(credentials)
235
- credentials = credentials.to_json if credentials.is_a?(Hash)
235
+ credentials = MultiJson.dump(credentials) if credentials.is_a?(Hash)
236
236
  encoded_creds = Base64.urlsafe_encode64(credentials)
237
237
  {
238
238
  'X-Registry-Auth' => encoded_creds
@@ -243,13 +243,13 @@ module Docker::Util
243
243
  if credentials.is_a?(String)
244
244
  credentials = JSON.parse(credentials, symbolize_names: true)
245
245
  end
246
- header = {
246
+ header = MultiJson.dump(
247
247
  credentials[:serveraddress].to_s => {
248
- "username" => credentials[:username].to_s,
249
- "password" => credentials[:password].to_s,
250
- "email" => credentials[:email].to_s
248
+ 'username' => credentials[:username].to_s,
249
+ 'password' => credentials[:password].to_s,
250
+ 'email' => credentials[:email].to_s
251
251
  }
252
- }.to_json
252
+ )
253
253
 
254
254
  encoded_header = Base64.urlsafe_encode64(header)
255
255
 
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.33.6'
3
+ VERSION = '1.34.0'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.16'
data/lib/docker/volume.rb CHANGED
@@ -31,9 +31,14 @@ class Docker::Volume
31
31
  # creates a volume with an arbitrary name
32
32
  def create(name, opts = {}, conn = Docker.connection)
33
33
  opts['Name'] = name
34
- resp = conn.post('/volumes/create', {}, :body => opts.to_json)
34
+ resp = conn.post('/volumes/create', {}, body: MultiJson.dump(opts))
35
35
  hash = Docker::Util.parse_json(resp) || {}
36
36
  new(conn, hash)
37
37
  end
38
+
39
+ def prune(conn = Docker.connection)
40
+ conn.post("/volumes/prune")
41
+ end
42
+
38
43
  end
39
44
  end
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.33.6
4
+ version: 1.34.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: 2017-06-27 00:00:00.000000000 Z
11
+ date: 2017-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -16,16 +16,16 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.38.0
19
+ version: 0.47.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.38.0
26
+ version: 0.47.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: json
28
+ name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="