docker-api 1.25.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/docker.rb +1 -0
- data/lib/docker/base.rb +1 -0
- data/lib/docker/util.rb +4 -6
- data/lib/docker/version.rb +1 -1
- data/lib/docker/volume.rb +42 -0
- data/spec/docker/util_spec.rb +4 -6
- data/spec/docker/volume_spec.rb +43 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 304e8688157679f2589c8b49a2d904f1166392ec
|
4
|
+
data.tar.gz: 25e942b796d147c68c27155c2cc17320219c8052
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c9daa7ce97a4ed0b9d1941a9b39e5ecba860c0557e7c500bf7551b2bc8c92db02c9ea08b7717ff6629d1e73f78e8e8acac1e8f56b571927e7c17e1a39171aca
|
7
|
+
data.tar.gz: a3d7ce445037a5c40bd7385b3a4754804228acf8f63a5d32ab2e621ef8aaacca7ae3358b96d8b78df011a3bb660eecadfd66c1ef2dcf4e9ee38075d12d43f1d2
|
data/lib/docker.rb
CHANGED
data/lib/docker/base.rb
CHANGED
@@ -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
|
data/lib/docker/util.rb
CHANGED
@@ -223,12 +223,10 @@ module Docker::Util
|
|
223
223
|
credentials = JSON.parse(credentials, symbolize_names: true)
|
224
224
|
end
|
225
225
|
header = {
|
226
|
-
|
227
|
-
credentials[:
|
228
|
-
|
229
|
-
|
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
|
|
data/lib/docker/version.rb
CHANGED
@@ -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
|
data/spec/docker/util_spec.rb
CHANGED
@@ -122,12 +122,10 @@ describe Docker::Util do
|
|
122
122
|
|
123
123
|
let(:credentials_object) {
|
124
124
|
{
|
125
|
-
:
|
126
|
-
:
|
127
|
-
|
128
|
-
|
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.
|
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-
|
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
|