docker-api 1.25.0 → 1.26.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: 51ab297af71a35ec5bec2a56f102f2257dbd473a
4
- data.tar.gz: 390dabb2d80beacd900b88ea4a9a7e6e687fae5d
3
+ metadata.gz: 304e8688157679f2589c8b49a2d904f1166392ec
4
+ data.tar.gz: 25e942b796d147c68c27155c2cc17320219c8052
5
5
  SHA512:
6
- metadata.gz: 74ec3e736efb4a8c4f962ee449710513887b0b8753b9484b91f418ce705d31817fdf34f09b873beea9f3b9ba3b6a64541faa103949ad6ebbd0fc28651a49ab8f
7
- data.tar.gz: dc566c61d644bafefb390c18301c497b69c0fd2abf60a26992e8184c6751563b95df66d47a23d14f5b254e5872c4ad2ecb1e88ae4536ca846b07e975c151ee7b
6
+ metadata.gz: 2c9daa7ce97a4ed0b9d1941a9b39e5ecba860c0557e7c500bf7551b2bc8c92db02c9ea08b7717ff6629d1e73f78e8e8acac1e8f56b571927e7c17e1a39171aca
7
+ data.tar.gz: a3d7ce445037a5c40bd7385b3a4754804228acf8f63a5d32ab2e621ef8aaacca7ae3358b96d8b78df011a3bb660eecadfd66c1ef2dcf4e9ee38075d12d43f1d2
@@ -31,6 +31,7 @@ module Docker
31
31
  require 'docker/messages'
32
32
  require 'docker/util'
33
33
  require 'docker/version'
34
+ require 'docker/volume'
34
35
  require 'docker/rake_task' if defined?(Rake::Task)
35
36
 
36
37
  def default_socket_url
@@ -18,6 +18,7 @@ module Docker::Base
18
18
 
19
19
  # The docker-api will some time return "ID" other times it will return "Id"
20
20
  # and other times it will return "id". This method normalize it to "id"
21
+ # The volumes endpoint returns Name instead of ID, added in the normalize function
21
22
  def normalize_hash(hash)
22
23
  hash["id"] ||= hash.delete("ID") || hash.delete("Id")
23
24
  end
@@ -223,12 +223,10 @@ module Docker::Util
223
223
  credentials = JSON.parse(credentials, symbolize_names: true)
224
224
  end
225
225
  header = {
226
- "configs" => {
227
- credentials[:serveraddress].to_s => {
228
- "username" => credentials[:username].to_s,
229
- "password" => credentials[:password].to_s,
230
- "email" => credentials[:email].to_s
231
- }
226
+ credentials[:serveraddress].to_s => {
227
+ "username" => credentials[:username].to_s,
228
+ "password" => credentials[:password].to_s,
229
+ "email" => credentials[:email].to_s
232
230
  }
233
231
  }.to_json
234
232
 
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.25.0'
3
+ VERSION = '1.26.0'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.16'
@@ -0,0 +1,42 @@
1
+ # class represents a Docker Volume
2
+ class Docker::Volume
3
+ include Docker::Base
4
+
5
+ # /volumes/volume_name doesnt return anything
6
+ def remove(opts = {}, conn = Docker.connection)
7
+ conn.delete("/volumes/#{id}")
8
+ end
9
+
10
+ def normalize_hash(hash)
11
+ hash['id'] ||= hash['Name']
12
+ end
13
+
14
+ class << self
15
+
16
+ # get details for a single volume
17
+ def get(name, conn = Docker.connection)
18
+ resp = conn.get("/volumes/#{name}")
19
+ hash = Docker::Util.parse_json(resp) || {}
20
+ new(conn, hash)
21
+ end
22
+
23
+ # /volumes endpoint returns an array of hashes incapsulated in an Volumes tag
24
+ def all(opts = {}, conn = Docker.connection)
25
+ resp = conn.get('/volumes')
26
+ hashes = Docker::Util.parse_json(resp) || []
27
+ if hashes.has_key?("Volumes")
28
+ hashes = hashes['Volumes']
29
+ end
30
+ hashes.map { |hash| new(conn, hash) }
31
+ end
32
+
33
+ # creates a volume with an arbitrary name
34
+ def create(name, conn = Docker.connection)
35
+ query = {}
36
+ query['name'] = name if name
37
+ resp = conn.post('/volumes/create', query, :body => query.to_json)
38
+ hash = Docker::Util.parse_json(resp) || {}
39
+ new(conn, hash)
40
+ end
41
+ end
42
+ end
@@ -122,12 +122,10 @@ describe Docker::Util do
122
122
 
123
123
  let(:credentials_object) {
124
124
  {
125
- :configs => {
126
- :'https://registry.com/' => {
127
- :username => 'test',
128
- :password => 'password',
129
- :email => 'test@example.com',
130
- }
125
+ :'https://registry.com/' => {
126
+ :username => 'test',
127
+ :password => 'password',
128
+ :email => 'test@example.com',
131
129
  }
132
130
  }.to_json
133
131
  }
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Docker::Volume, :docker_1_9 do
4
+ let(:name) { "ArbitraryNameForTheRakeTestVolume" }
5
+
6
+ describe '.create' do
7
+ let(:volume) { Docker::Volume.create(name) }
8
+
9
+ after { volume.remove }
10
+
11
+ it 'creates a volume' do
12
+ expect(volume.id).to eq(name)
13
+ end
14
+ end
15
+
16
+ describe '.get' do
17
+ let(:volume) { Docker::Volume.get(name) }
18
+
19
+ before { Docker::Volume.create(name) }
20
+ after { volume.remove }
21
+
22
+ it 'gets volume details' do
23
+ expect(volume.id).to eq(name)
24
+ expect(volume.info).to_not be_empty
25
+ end
26
+ end
27
+
28
+ describe '.all' do
29
+ after { Docker::Volume.get(name).remove }
30
+
31
+ it 'gets a list of volumes' do
32
+ expect { Docker::Volume.create(name) }.to change { Docker::Volume.all.length }.by(1)
33
+ end
34
+ end
35
+
36
+ describe '#remove' do
37
+ it 'removes a volume' do
38
+ volume = Docker::Volume.create(name)
39
+ expect { volume.remove }.to change { Docker::Volume.all.length }.by(-1)
40
+ end
41
+ end
42
+
43
+ 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.25.0
4
+ version: 1.26.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-01-15 00:00:00.000000000 Z
11
+ date: 2016-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -186,6 +186,7 @@ files:
186
186
  - lib/docker/rake_task.rb
187
187
  - lib/docker/util.rb
188
188
  - lib/docker/version.rb
189
+ - lib/docker/volume.rb
189
190
  - lib/excon/middlewares/hijack.rb
190
191
  - script/install_dependencies.sh
191
192
  - spec/docker/connection_spec.rb
@@ -197,6 +198,7 @@ files:
197
198
  - spec/docker/messages_stack.rb
198
199
  - spec/docker/network_spec.rb
199
200
  - spec/docker/util_spec.rb
201
+ - spec/docker/volume_spec.rb
200
202
  - spec/docker_spec.rb
201
203
  - spec/fixtures/build_from_dir/Dockerfile
202
204
  - spec/fixtures/export.tar
@@ -236,6 +238,7 @@ test_files:
236
238
  - spec/docker/messages_stack.rb
237
239
  - spec/docker/network_spec.rb
238
240
  - spec/docker/util_spec.rb
241
+ - spec/docker/volume_spec.rb
239
242
  - spec/docker_spec.rb
240
243
  - spec/fixtures/build_from_dir/Dockerfile
241
244
  - spec/fixtures/export.tar