docker-api 1.13.4 → 1.13.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d925f4110703e04fbfa310061a380ad4349e43ef
4
+ data.tar.gz: e9da0d1fd6edd34680174d1d9aea318220db456d
5
+ SHA512:
6
+ metadata.gz: e69243227661c01870d30f3d2219bf718dbeb3f1a14f362c6d4c2a27a7fc09d42f29602814bf2d3a4765f424b528c7a221541d0b6649f6924f43711a2f5aa824
7
+ data.tar.gz: 9b008cc2c6adb0ca30cdc8d37e5ce87a12dc83fffaf39c0d582f969603e1c4a6d6dd7859f3e21b84c758da93e9421499d85c2b7f3f87c6f1a6b396eb6d837591
data/README.md CHANGED
@@ -172,6 +172,10 @@ Docker::Image.all
172
172
  Docker::Image.get('df4f1bdecf40')
173
173
  # => Docker::Image { :id => eb693ec80, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }
174
174
 
175
+ # Check if an image with a given id exists on the server.
176
+ Docker::Image.exist?('ef723dcdac09')
177
+ # => true
178
+
175
179
  # Search the Docker registry.
176
180
  Docker::Image.search('term' => 'sshd')
177
181
  # => [Docker::Image { :id => cespare/sshd, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => johnfuller/sshd, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => dhrp/mongodb-sshd, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => rayang2004/sshd, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => dhrp/sshd, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => toorop/daemontools-sshd, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => toorop/daemontools-sshd-nginx, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => toorop/daemontools-sshd-nginx-php-fpm, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => mbkan/lamp, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => toorop/golang, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => wma55/u1210sshd, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => jdswinbank/sshd, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }, Docker::Image { :id => vgauthier/sshd, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }]
@@ -110,6 +110,14 @@ class Docker::Image
110
110
  new(conn, hash)
111
111
  end
112
112
 
113
+ # Check if an image exists.
114
+ def exist?(id, opts = {}, conn = Docker.connection)
115
+ get(id, opts, conn)
116
+ true
117
+ rescue Docker::Error::NotFoundError
118
+ false
119
+ end
120
+
113
121
  # Return every Image.
114
122
  def all(opts = {}, conn = Docker.connection)
115
123
  hashes = Docker::Util.parse_json(conn.get('/images/json', opts)) || []
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.13.4'
3
+ VERSION = '1.13.5'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.12'
@@ -1,4 +1,6 @@
1
1
  module Excon
2
+ VALID_REQUEST_KEYS << :hijack_block
3
+
2
4
  module Middleware
3
5
  # Hijack is an Excon middleware which parses response headers and then
4
6
  # yields the underlying TCP socket for raw TCP communication (used to
@@ -281,6 +281,37 @@ describe Docker::Image do
281
281
  end
282
282
  end
283
283
 
284
+ describe '.exist?' do
285
+ subject { described_class }
286
+ let(:exists) { subject.exist?(image_name) }
287
+
288
+ context 'when the image does exist' do
289
+ let(:image_name) { 'base' }
290
+
291
+ it 'returns true', :vcr do
292
+ expect(exists).to eq(true)
293
+ end
294
+ end
295
+
296
+ context 'when the image does not exist' do
297
+ let(:image_name) { 'abcdefghijkl' }
298
+
299
+ before do
300
+ Docker.options = { :mock => true }
301
+ Excon.stub({ :method => :get }, { :status => 404 })
302
+ end
303
+
304
+ after do
305
+ Docker.options = {}
306
+ Excon.stubs.shift
307
+ end
308
+
309
+ it 'return false', :vcr do
310
+ expect(exists).to eq(false)
311
+ end
312
+ end
313
+ end
314
+
284
315
  describe '.import' do
285
316
  subject { described_class }
286
317
 
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: unix:///var/run/docker.sock/v1.12/images/base/json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Swipely/Docker-API 1.13.4
12
+ Content-Type:
13
+ - text/plain
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ !binary "Q29udGVudC1UeXBl":
20
+ - !binary |-
21
+ YXBwbGljYXRpb24vanNvbg==
22
+ !binary "RGF0ZQ==":
23
+ - !binary |-
24
+ VHVlLCAzMCBTZXAgMjAxNCAxNDo1MzoxNiBHTVQ=
25
+ !binary "Q29udGVudC1MZW5ndGg=":
26
+ - !binary |-
27
+ MTU4MQ==
28
+ body:
29
+ encoding: US-ASCII
30
+ string: ! '{"Architecture":"amd64","Author":"","Comment":"","Config":{"AttachStderr":false,"AttachStdin":false,"AttachStdout":false,"Cmd":["/bin/bash"],"CpuShares":0,"Cpuset":"","Domainname":"","Entrypoint":["/bin/sh","-c","/bin/bash
31
+ -l -c bin/hoosegow"],"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"ExposedPorts":null,"Hostname":"265bbe22abe7","Image":"697157367a35a2a0c7283894ab3035c069ae48ff6fb6d5cf10747deee5e3a723","Memory":0,"MemorySwap":0,"NetworkDisabled":false,"OnBuild":[],"OpenStdin":false,"PortSpecs":null,"StdinOnce":false,"Tty":false,"User":"","Volumes":null,"WorkingDir":"/hoosegow"},"Container":"4fabe9ab2546a3dd5edc70571ffa2839bc327109716a17d3054fbd5cddb68400","ContainerConfig":{"AttachStderr":false,"AttachStdin":false,"AttachStdout":false,"Cmd":["/bin/sh","-c","#(nop)
32
+ ENTRYPOINT [/bin/sh -c /bin/bash -l -c bin/hoosegow]"],"CpuShares":0,"Cpuset":"","Domainname":"","Entrypoint":["/bin/sh","-c","/bin/bash
33
+ -l -c bin/hoosegow"],"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"ExposedPorts":null,"Hostname":"265bbe22abe7","Image":"697157367a35a2a0c7283894ab3035c069ae48ff6fb6d5cf10747deee5e3a723","Memory":0,"MemorySwap":0,"NetworkDisabled":false,"OnBuild":[],"OpenStdin":false,"PortSpecs":null,"StdinOnce":false,"Tty":false,"User":"","Volumes":null,"WorkingDir":"/hoosegow"},"Created":"2014-09-30T14:47:46.62397332Z","DockerVersion":"1.0.1","Id":"ba5d55a9e74b5274f06653c2717f2251d8a37a3ac837034d8d2e5a6259b9553d","Os":"linux","Parent":"697157367a35a2a0c7283894ab3035c069ae48ff6fb6d5cf10747deee5e3a723","Size":0}
34
+
35
+ '
36
+ http_version:
37
+ recorded_at: Tue, 30 Sep 2014 14:53:16 GMT
38
+ recorded_with: VCR 2.9.3
metadata CHANGED
@@ -1,190 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.4
5
- prerelease:
4
+ version: 1.13.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Swipely, Inc.
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-09-29 00:00:00.000000000 Z
11
+ date: 2014-10-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: excon
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.38.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.38.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: archive-tar-minitar
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: '3.0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: '3.0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec-its
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: cane
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: pry
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: vcr
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: 2.7.0
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: 2.7.0
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: simplecov
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - ">="
164
144
  - !ruby/object:Gem::Version
165
145
  version: '0'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - ">="
172
151
  - !ruby/object:Gem::Version
173
152
  version: '0'
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: webmock
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - ">="
180
158
  - !ruby/object:Gem::Version
181
159
  version: '0'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - ">="
188
165
  - !ruby/object:Gem::Version
189
166
  version: '0'
190
167
  description: A simple REST client for the Docker Remote API
@@ -196,10 +173,10 @@ executables: []
196
173
  extensions: []
197
174
  extra_rdoc_files: []
198
175
  files:
199
- - .cane
200
- - .gitignore
201
- - .simplecov
202
- - .travis.yml
176
+ - ".cane"
177
+ - ".gitignore"
178
+ - ".simplecov"
179
+ - ".travis.yml"
203
180
  - Gemfile
204
181
  - README.md
205
182
  - Rakefile
@@ -271,6 +248,7 @@ files:
271
248
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_no_query_parameters/builds_the_image.yml
272
249
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_specifying_a_repo_in_the_query_parameters/builds_the_image_and_tags_it.yml
273
250
  - spec/vcr/Docker_Image/_create/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash/sets_the_id_and_sends_Docker_creds.yml
251
+ - spec/vcr/Docker_Image/_exist_/when_the_image_does_exist/returns_true.yml
274
252
  - spec/vcr/Docker_Image/_get/when_the_image_does_exist/returns_the_new_image.yml
275
253
  - spec/vcr/Docker_Image/_history/returns_the_history_of_the_Image.yml
276
254
  - spec/vcr/Docker_Image/_import/when_the_argument_is_a_URI/when_the_URI_is_invalid/raises_an_error.yml
@@ -295,27 +273,26 @@ files:
295
273
  homepage: https://github.com/swipely/docker-api
296
274
  licenses:
297
275
  - MIT
276
+ metadata: {}
298
277
  post_install_message:
299
278
  rdoc_options: []
300
279
  require_paths:
301
280
  - lib
302
281
  required_ruby_version: !ruby/object:Gem::Requirement
303
- none: false
304
282
  requirements:
305
- - - ! '>='
283
+ - - ">="
306
284
  - !ruby/object:Gem::Version
307
285
  version: '0'
308
286
  required_rubygems_version: !ruby/object:Gem::Requirement
309
- none: false
310
287
  requirements:
311
- - - ! '>='
288
+ - - ">="
312
289
  - !ruby/object:Gem::Version
313
290
  version: '0'
314
291
  requirements: []
315
292
  rubyforge_project:
316
- rubygems_version: 1.8.23.2
293
+ rubygems_version: 2.2.2
317
294
  signing_key:
318
- specification_version: 3
295
+ specification_version: 4
319
296
  summary: A simple REST client for the Docker Remote API
320
297
  test_files:
321
298
  - spec/docker/connection_spec.rb
@@ -373,6 +350,7 @@ test_files:
373
350
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_no_query_parameters/builds_the_image.yml
374
351
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_specifying_a_repo_in_the_query_parameters/builds_the_image_and_tags_it.yml
375
352
  - spec/vcr/Docker_Image/_create/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash/sets_the_id_and_sends_Docker_creds.yml
353
+ - spec/vcr/Docker_Image/_exist_/when_the_image_does_exist/returns_true.yml
376
354
  - spec/vcr/Docker_Image/_get/when_the_image_does_exist/returns_the_new_image.yml
377
355
  - spec/vcr/Docker_Image/_history/returns_the_history_of_the_Image.yml
378
356
  - spec/vcr/Docker_Image/_import/when_the_argument_is_a_URI/when_the_URI_is_invalid/raises_an_error.yml