docker-api 1.13.1 → 1.13.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/docker.rb CHANGED
@@ -70,12 +70,12 @@ module Docker
70
70
  end
71
71
 
72
72
  # Get the version of Go, Docker, and optionally the Git commit.
73
- def version
73
+ def version(connection = self.connection)
74
74
  Util.parse_json(connection.get('/version'))
75
75
  end
76
76
 
77
77
  # Get more information about the Docker server.
78
- def info
78
+ def info(connection = self.connection)
79
79
  Util.parse_json(connection.get('/info'))
80
80
  end
81
81
 
@@ -77,7 +77,7 @@ private
77
77
  :headers => { 'Content-Type' => content_type,
78
78
  'User-Agent' => user_agent,
79
79
  }.merge(headers),
80
- :expects => (200..204),
80
+ :expects => (200..204).to_a << 304,
81
81
  :idempotent => http_method == :get,
82
82
  :request_block => block
83
83
  }.merge(opts).reject { |_, v| v.nil? }
@@ -26,7 +26,7 @@ class Docker::Container
26
26
  # UnexpectedResponseError is raised.
27
27
  def run(cmd, time = 1000)
28
28
  if (code = tap(&:start).wait(time)['StatusCode']).zero?
29
- commit.run(cmd).tap(&:start)
29
+ commit.run(cmd)
30
30
  else
31
31
  raise UnexpectedResponseError, "Command returned status code #{code}."
32
32
  end
data/lib/docker/image.rb CHANGED
@@ -192,15 +192,15 @@ class Docker::Image
192
192
 
193
193
  private
194
194
 
195
- # A method to build auth headers and merge them into headers sent
196
- # by build_from_dir.
195
+ # A method to build the config header and merge it into the
196
+ # headers sent by build_from_dir.
197
197
  def self.build_headers(creds)
198
198
  credentials = creds || Docker.creds || {}
199
- auth_header = Docker::Util.build_auth_header(credentials.to_json)
199
+ config_header = Docker::Util.build_config_header(credentials)
200
200
 
201
201
  headers = { 'Content-Type' => 'application/tar',
202
202
  'Transfer-Encoding' => 'chunked' }
203
- headers = headers.merge(auth_header) if auth_header
203
+ headers = headers.merge(config_header) if config_header
204
204
  headers
205
205
  end
206
206
 
data/lib/docker/util.rb CHANGED
@@ -77,8 +77,28 @@ module Docker::Util
77
77
  credentials = credentials.to_json if credentials.is_a?(Hash)
78
78
  encoded_creds = Base64.encode64(credentials).gsub(/\n/, '')
79
79
  {
80
- 'X-Registry-Auth' => encoded_creds,
81
- 'X-Registry-Config' => encoded_creds,
80
+ 'X-Registry-Auth' => encoded_creds
81
+ }
82
+ end
83
+
84
+ def build_config_header(credentials)
85
+ if credentials.is_a?(String)
86
+ credentials = JSON.parse(credentials, symbolize_names: true)
87
+ end
88
+ header = {
89
+ "configs" => {
90
+ credentials[:serveraddress].to_s => {
91
+ "username" => credentials[:username].to_s,
92
+ "password" => credentials[:password].to_s,
93
+ "email" => credentials[:email].to_s
94
+ }
95
+ }
96
+ }.to_json
97
+
98
+ encoded_header = Base64.encode64(header).gsub(/\n/, '')
99
+
100
+ {
101
+ 'X-Registry-Config' => encoded_header
82
102
  }
83
103
  end
84
104
  end
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.13.1'
3
+ VERSION = '1.13.2'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.12'
@@ -455,14 +455,15 @@ describe Docker::Image do
455
455
  {
456
456
  :username => 'nahiluhmot',
457
457
  :password => '*********',
458
- :email => 'hulihan.tom159@gmail.com'
458
+ :email => 'hulihan.tom159@gmail.com',
459
+ :serveraddress => 'https://index.docker.io/v1'
459
460
  }
460
461
  }
461
462
 
462
463
  before { Docker.creds = creds }
463
464
 
464
- it 'sends Docker.creds', :vcr do
465
- expect(image.info[:headers].keys).to include('X-Registry-Auth')
465
+ it 'sends X-Registry-Config header', :vcr do
466
+ expect(image.info[:headers].keys).to include('X-Registry-Config')
466
467
  end
467
468
  end
468
469
  end
@@ -86,17 +86,16 @@ describe Docker::Util do
86
86
  }
87
87
  let(:credential_string) { credentials.to_json }
88
88
  let(:encoded_creds) { Base64.encode64(credential_string).gsub(/\n/, '') }
89
- let(:expected_headers) {
89
+ let(:expected_header) {
90
90
  {
91
- 'X-Registry-Auth' => encoded_creds,
92
- 'X-Registry-Config' => encoded_creds
91
+ 'X-Registry-Auth' => encoded_creds
93
92
  }
94
93
  }
95
94
 
96
95
 
97
96
  context 'given credentials as a Hash' do
98
97
  it 'returns an X-Registry-Auth header encoded' do
99
- expect(subject.build_auth_header(credentials)).to eq(expected_headers)
98
+ expect(subject.build_auth_header(credentials)).to eq(expected_header)
100
99
  end
101
100
  end
102
101
 
@@ -104,7 +103,53 @@ describe Docker::Util do
104
103
  it 'returns an X-Registry-Auth header encoded' do
105
104
  expect(
106
105
  subject.build_auth_header(credential_string)
107
- ).to eq(expected_headers)
106
+ ).to eq(expected_header)
107
+ end
108
+ end
109
+ end
110
+
111
+ describe '.build_config_header' do
112
+ subject { described_class }
113
+
114
+ let(:credentials) {
115
+ {
116
+ :username => 'test',
117
+ :password => 'password',
118
+ :email => 'test@example.com',
119
+ :serveraddress => 'https://registry.com/'
120
+ }
121
+ }
122
+
123
+ let(:credentials_object) {
124
+ {
125
+ :configs => {
126
+ :'https://registry.com/' => {
127
+ :username => 'test',
128
+ :password => 'password',
129
+ :email => 'test@example.com',
130
+ }
131
+ }
132
+ }.to_json
133
+ }
134
+
135
+ let(:encoded_creds) { Base64.encode64(credentials_object).gsub(/\n/, '') }
136
+ let(:expected_header) {
137
+ {
138
+ 'X-Registry-Config' => encoded_creds
139
+ }
140
+ }
141
+
142
+ context 'given credentials as a Hash' do
143
+ it 'returns an X-Registry-Config header encoded' do
144
+ expect(subject.build_config_header(credentials)).to eq(expected_header)
145
+ end
146
+ end
147
+
148
+ context 'given credentials as a String' do
149
+ it 'returns an X-Registry-Config header encoded' do
150
+ expect(
151
+ subject.build_config_header(credentials.to_json)
152
+ ).to eq(expected_header)
108
153
  end
109
154
  end
110
155
  end
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: unix:///var/run/docker.sock/v1.12/build
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Swipely/Docker-API 1.13.1
12
+ Content-Type:
13
+ - application/tar
14
+ Transfer-Encoding:
15
+ - chunked
16
+ X-Registry-Config:
17
+ - eyJjb25maWdzIjp7Imh0dHBzOi8vaW5kZXguZG9ja2VyLmlvL3YxIjp7InVzZXJuYW1lIjoibmFoaWx1aG1vdCIsInBhc3N3b3JkIjoiKioqKioqKioqIiwiZW1haWwiOiJodWxpaGFuLnRvbTE1OUBnbWFpbC5jb20ifX19
18
+ response:
19
+ status:
20
+ code: 200
21
+ message:
22
+ headers:
23
+ Content-Type:
24
+ - application/json
25
+ Date:
26
+ - Mon, 21 Jul 2014 17:07:50 GMT
27
+ Connection:
28
+ - close
29
+ Transfer-Encoding:
30
+ - ''
31
+ body:
32
+ encoding: US-ASCII
33
+ string: ! "{\"stream\":\"Step 0 : from base\\n\"}\r\n{\"stream\":\" ---\\u003e
34
+ b750fe79269d\\n\"}\r\n{\"stream\":\"Step 1 : add / /\\n\"}\r\n{\"stream\":\"
35
+ ---\\u003e 282d877698a4\\n\"}\r\n{\"stream\":\"Removing intermediate container
36
+ f76554ba0d24\\n\"}\r\n{\"stream\":\"Successfully built 282d877698a4\\n\"}\r\n"
37
+ http_version:
38
+ recorded_at: Mon, 21 Jul 2014 17:07:53 GMT
39
+ recorded_with: VCR 2.9.2
metadata CHANGED
@@ -1,74 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.1
4
+ version: 1.13.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Swipely, Inc.
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-09 00:00:00.000000000 Z
12
+ date: 2014-07-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: excon
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 0.38.0
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 0.38.0
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: json
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: archive-tar-minitar
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: rspec
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ~>
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ~>
81
92
  - !ruby/object:Gem::Version
@@ -83,85 +94,97 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: rspec-its
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - '>='
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - '>='
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: cane
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
- - - '>='
115
+ - - ! '>='
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
- - - '>='
123
+ - - ! '>='
109
124
  - !ruby/object:Gem::Version
110
125
  version: '0'
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: pry
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
- - - '>='
131
+ - - ! '>='
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
- - - '>='
139
+ - - ! '>='
123
140
  - !ruby/object:Gem::Version
124
141
  version: '0'
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: vcr
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
- - - '>='
147
+ - - ! '>='
130
148
  - !ruby/object:Gem::Version
131
149
  version: 2.7.0
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
- - - '>='
155
+ - - ! '>='
137
156
  - !ruby/object:Gem::Version
138
157
  version: 2.7.0
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: simplecov
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
- - - '>='
163
+ - - ! '>='
144
164
  - !ruby/object:Gem::Version
145
165
  version: '0'
146
166
  type: :development
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
- - - '>='
171
+ - - ! '>='
151
172
  - !ruby/object:Gem::Version
152
173
  version: '0'
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: webmock
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
- - - '>='
179
+ - - ! '>='
158
180
  - !ruby/object:Gem::Version
159
181
  version: '0'
160
182
  type: :development
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
- - - '>='
187
+ - - ! '>='
165
188
  - !ruby/object:Gem::Version
166
189
  version: '0'
167
190
  description: A simple REST client for the Docker Remote API
@@ -244,6 +267,7 @@ files:
244
267
  - spec/vcr/Docker_Image/_build/with_an_invalid_Dockerfile/throws_a_UnexpectedResponseError.yml
245
268
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_a_block_capturing_build_output/calls_the_block_and_passes_build_output.yml
246
269
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_credentials_passed/sends_Docker_creds.yml
270
+ - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_credentials_passed/sends_X-Registry-Config_header.yml
247
271
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_no_query_parameters/builds_the_image.yml
248
272
  - 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
249
273
  - 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
@@ -271,26 +295,27 @@ files:
271
295
  homepage: https://github.com/swipely/docker-api
272
296
  licenses:
273
297
  - MIT
274
- metadata: {}
275
298
  post_install_message:
276
299
  rdoc_options: []
277
300
  require_paths:
278
301
  - lib
279
302
  required_ruby_version: !ruby/object:Gem::Requirement
303
+ none: false
280
304
  requirements:
281
- - - '>='
305
+ - - ! '>='
282
306
  - !ruby/object:Gem::Version
283
307
  version: '0'
284
308
  required_rubygems_version: !ruby/object:Gem::Requirement
309
+ none: false
285
310
  requirements:
286
- - - '>='
311
+ - - ! '>='
287
312
  - !ruby/object:Gem::Version
288
313
  version: '0'
289
314
  requirements: []
290
315
  rubyforge_project:
291
- rubygems_version: 2.0.14
316
+ rubygems_version: 1.8.23.2
292
317
  signing_key:
293
- specification_version: 4
318
+ specification_version: 3
294
319
  summary: A simple REST client for the Docker Remote API
295
320
  test_files:
296
321
  - spec/docker/connection_spec.rb
@@ -344,6 +369,7 @@ test_files:
344
369
  - spec/vcr/Docker_Image/_build/with_an_invalid_Dockerfile/throws_a_UnexpectedResponseError.yml
345
370
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_a_block_capturing_build_output/calls_the_block_and_passes_build_output.yml
346
371
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_credentials_passed/sends_Docker_creds.yml
372
+ - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_credentials_passed/sends_X-Registry-Config_header.yml
347
373
  - spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_no_query_parameters/builds_the_image.yml
348
374
  - 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
349
375
  - 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
@@ -368,4 +394,3 @@ test_files:
368
394
  - spec/vcr/Docker_Image/_run/when_the_argument_is_nil/no_command_configured_in_image/should_raise_an_error_if_no_command_is_specified.yml
369
395
  - spec/vcr/Docker_Image/_search/materializes_each_Image_into_a_Docker_Image.yml
370
396
  - spec/vcr/Docker_Image/_tag/tags_the_image_with_the_repo_name.yml
371
- has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: c65d0d14dc98274bae2d57338d68b53e340b17b6
4
- data.tar.gz: d1d3a1ce41bc4c4a38b720ab67b0c2ef91e7089f
5
- SHA512:
6
- metadata.gz: ed39d770944b0ab5872bc62176b1fd529de09b920ad5c12665b8658f4e06356653fb4d01a0a4ea667d8577aaff81888e169ed581059f0ce369f5108c5522be55
7
- data.tar.gz: 7233f50f86047421d4cc40cf94f34765670674ad33206277260167af885750a6c798a319eb315cb4d129e2ac665092ade0d394c4ebcb39fe951073796ac9206f