docker-api 1.19.0 → 1.20.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: f014fbf8eec822892584240bab7d8afa3ba9005e
4
- data.tar.gz: 904edd7019308e5c17cdfb326d1ef49fc9a161b8
3
+ metadata.gz: 8561445c82a9399f7fc303f3a0980b9a0435cb0e
4
+ data.tar.gz: 436d9e686521e49445dc2e6f786998f2dfd81730
5
5
  SHA512:
6
- metadata.gz: 1a25da3ac701b0dc000b4e04b694b04c82fc25f7f18be51202eb94e379eee8c17c5e948089e7ef6dd5e656a279df94eb27d9b9c6b6dd70837a77e5a8be9fc3c0
7
- data.tar.gz: eb715f87b92d6acbcde4522463ba0a07f18b1f464fd1c8d75937240054911191dd515ab291544439e2081c1ccaa35a7b76c82b4c9fb5da8aa1ec5167e8a8f359
6
+ metadata.gz: b42de620e15d9b503791ef23fc7bdd9598f4541ddff03d7a7b306b6e48ba30ec6c263038e2719c37405e3176ca9fc05042d5a864ded610f1664362bb7051ec62
7
+ data.tar.gz: f75aec1ebe9c929cca1bac68a0a46e0c474e03b73259c87c7f72ba30ba5e0dbe86f1395a45aa092553a8d50b94d4216b975c7de23ad5c385af8b3e3df87cc5e6
data/docker-api.gemspec CHANGED
@@ -16,7 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Docker::VERSION
17
17
  gem.add_dependency 'excon', '>= 0.38.0'
18
18
  gem.add_dependency 'json'
19
- gem.add_dependency 'archive-tar-minitar'
20
19
  gem.add_development_dependency 'rake'
21
20
  gem.add_development_dependency 'rspec', '~> 3.0'
22
21
  gem.add_development_dependency 'rspec-its'
data/lib/docker.rb CHANGED
@@ -3,8 +3,8 @@ require 'json'
3
3
  require 'excon'
4
4
  require 'tempfile'
5
5
  require 'base64'
6
+ require 'find'
6
7
  require 'rubygems/package'
7
- require 'archive/tar/minitar'
8
8
  require 'uri'
9
9
  require 'open-uri'
10
10
 
@@ -49,7 +49,7 @@ class Docker::Connection
49
49
  rescue Excon::Errors::NotFound => ex
50
50
  raise NotFoundError, ex.message
51
51
  rescue Excon::Errors::Conflict => ex
52
- raise ConfictError, ex.message
52
+ raise ConflictError, ex.message
53
53
  rescue Excon::Errors::InternalServerError => ex
54
54
  raise ServerError, ex.response.data[:body]
55
55
  rescue Excon::Errors::Timeout => ex
@@ -138,6 +138,12 @@ class Docker::Container
138
138
  connection.get(path_for(:logs), opts)
139
139
  end
140
140
 
141
+ def rename(new_name)
142
+ query = {}
143
+ query['name'] = new_name
144
+ connection.post(path_for(:rename), query)
145
+ end
146
+
141
147
  def streaming_logs(opts = {}, &block)
142
148
  msgs = Docker::Messages.new
143
149
  excon_params = {response_block: Docker::Util.attach_for(block, msgs, false)}
data/lib/docker/error.rb CHANGED
@@ -18,7 +18,7 @@ module Docker::Error
18
18
  class NotFoundError < DockerError; end
19
19
 
20
20
  # Raised when a request returns a 409.
21
- class ConfictError < DockerError; end
21
+ class ConflictError < DockerError; end
22
22
 
23
23
  # Raised when a request returns a 500.
24
24
  class ServerError < DockerError; end
data/lib/docker/event.rb CHANGED
@@ -1,4 +1,4 @@
1
- # This class represents a Docker Image.
1
+ # This class represents a Docker Event.
2
2
  class Docker::Event
3
3
  include Docker::Error
4
4
 
data/lib/docker/util.rb CHANGED
@@ -123,14 +123,33 @@ module Docker::Util
123
123
  end
124
124
 
125
125
  def create_dir_tar(directory)
126
- cwd = FileUtils.pwd
127
- tempfile_name = Dir::Tmpname.create('out') {}
128
- tempfile = File.open(tempfile_name, 'wb+')
129
- FileUtils.cd(directory)
130
- Archive::Tar::Minitar.pack('.', tempfile)
126
+ tempfile = create_temp_file
127
+ directory += '/' unless directory.end_with?('/')
128
+
129
+ create_relative_dir_tar(directory, tempfile)
130
+
131
131
  File.new(tempfile.path, 'r')
132
- ensure
133
- FileUtils.cd(cwd)
132
+ end
133
+
134
+ def create_relative_dir_tar(directory, output)
135
+ Gem::Package::TarWriter.new(output) do |tar|
136
+ Find.find(directory) do |prefixed_file_name|
137
+ stat = File.stat(prefixed_file_name)
138
+ next unless stat.file?
139
+
140
+ unprefixed_file_name = prefixed_file_name[directory.length..-1]
141
+ tar.add_file_simple(
142
+ unprefixed_file_name, stat.mode, stat.size
143
+ ) do |tar_file|
144
+ IO.copy_stream(File.open(prefixed_file_name, 'rb'), tar_file)
145
+ end
146
+ end
147
+ end
148
+ end
149
+
150
+ def create_temp_file
151
+ tempfile_name = Dir::Tmpname.create('out') {}
152
+ File.open(tempfile_name, 'wb+')
134
153
  end
135
154
 
136
155
  def extract_id(body)
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.19.0'
3
+ VERSION = '1.20.0'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.16'
@@ -98,6 +98,24 @@ describe Docker::Container do
98
98
  end
99
99
  end
100
100
 
101
+ describe '#rename' do
102
+ subject {
103
+ described_class.create({
104
+ 'name' => 'foo',
105
+ 'Cmd' => %w[true],
106
+ 'Image' => 'debian:wheezy'
107
+ })
108
+ }
109
+
110
+ before { subject.start }
111
+ after(:each) { subject.kill!.remove }
112
+
113
+ it 'renames the container', :vcr do
114
+ subject.rename('bar')
115
+ expect(subject.json["Name"]).to eq "bar"
116
+ end
117
+ end
118
+
101
119
  describe '#changes' do
102
120
  subject {
103
121
  described_class.create(
@@ -0,0 +1,149 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<DOCKER_HOST>/v1.16/containers/create?name=foo"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"Cmd":["true"],"Image":"debian:wheezy"}'
9
+ headers:
10
+ User-Agent:
11
+ - Swipely/Docker-API 1.19.0
12
+ Content-Type:
13
+ - application/json
14
+ response:
15
+ status:
16
+ code: 201
17
+ message:
18
+ headers:
19
+ Content-Type:
20
+ - application/json
21
+ Date:
22
+ - Mon, 23 Feb 2015 19:44:39 GMT
23
+ Content-Length:
24
+ - '90'
25
+ body:
26
+ encoding: UTF-8
27
+ string: |
28
+ {"Id":"9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2","Warnings":null}
29
+ http_version:
30
+ recorded_at: Mon, 23 Feb 2015 19:44:39 GMT
31
+ - request:
32
+ method: post
33
+ uri: "<DOCKER_HOST>/v1.16/containers/9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2/start"
34
+ body:
35
+ encoding: UTF-8
36
+ string: "{}"
37
+ headers:
38
+ User-Agent:
39
+ - Swipely/Docker-API 1.19.0
40
+ Content-Type:
41
+ - application/json
42
+ response:
43
+ status:
44
+ code: 204
45
+ message:
46
+ headers:
47
+ Date:
48
+ - Mon, 23 Feb 2015 19:44:39 GMT
49
+ body:
50
+ encoding: UTF-8
51
+ string: ''
52
+ http_version:
53
+ recorded_at: Mon, 23 Feb 2015 19:44:39 GMT
54
+ - request:
55
+ method: post
56
+ uri: "<DOCKER_HOST>/v1.16/containers/9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2/rename?name=bar"
57
+ body:
58
+ encoding: US-ASCII
59
+ string: ''
60
+ headers:
61
+ User-Agent:
62
+ - Swipely/Docker-API 1.19.0
63
+ Content-Type:
64
+ - text/plain
65
+ response:
66
+ status:
67
+ code: 204
68
+ message:
69
+ headers:
70
+ Date:
71
+ - Mon, 23 Feb 2015 19:44:39 GMT
72
+ body:
73
+ encoding: UTF-8
74
+ string: ''
75
+ http_version:
76
+ recorded_at: Mon, 23 Feb 2015 19:44:39 GMT
77
+ - request:
78
+ method: get
79
+ uri: "<DOCKER_HOST>/v1.16/containers/9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2/json"
80
+ body:
81
+ encoding: US-ASCII
82
+ string: ''
83
+ headers:
84
+ User-Agent:
85
+ - Swipely/Docker-API 1.19.0
86
+ Content-Type:
87
+ - text/plain
88
+ response:
89
+ status:
90
+ code: 200
91
+ message:
92
+ headers:
93
+ Content-Type:
94
+ - application/json
95
+ Date:
96
+ - Mon, 23 Feb 2015 19:44:39 GMT
97
+ body:
98
+ encoding: UTF-8
99
+ string: |
100
+ {"AppArmorProfile":"","Args":[],"Config":{"AttachStderr":false,"AttachStdin":false,"AttachStdout":false,"Cmd":["true"],"CpuShares":0,"Cpuset":"","Domainname":"","Entrypoint":null,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"ExposedPorts":null,"Hostname":"9da0d07895ab","Image":"debian:wheezy","MacAddress":"","Memory":0,"MemorySwap":0,"NetworkDisabled":false,"OnBuild":null,"OpenStdin":false,"PortSpecs":null,"StdinOnce":false,"Tty":false,"User":"","Volumes":null,"WorkingDir":""},"Created":"2015-02-23T19:44:39.002713163Z","Driver":"aufs","ExecDriver":"native-0.2","ExecIDs":null,"HostConfig":{"Binds":null,"CapAdd":null,"CapDrop":null,"ContainerIDFile":"","Devices":null,"Dns":null,"DnsSearch":null,"ExtraHosts":null,"IpcMode":"","Links":null,"LxcConf":null,"NetworkMode":"","PidMode":"","PortBindings":null,"Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"RestartPolicy":{"MaximumRetryCount":0,"Name":""},"SecurityOpt":null,"VolumesFrom":null},"HostnamePath":"/data/docker/containers/9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2/hostname","HostsPath":"/data/docker/containers/9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2/hosts","Id":"9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2","Image":"479215127fa7b852902ed734f3a7ac69177c0d4d9446ad3a1648938230c3c8ab","MountLabel":"","Name":"bar","NetworkSettings":{"Bridge":"docker0","Gateway":"172.17.42.1","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"IPAddress":"172.17.8.30","IPPrefixLen":16,"IPv6Gateway":"","LinkLocalIPv6Address":"fe80::42:acff:fe11:81e","LinkLocalIPv6PrefixLen":64,"MacAddress":"02:42:ac:11:08:1e","PortMapping":null,"Ports":{}},"Path":"true","ProcessLabel":"","ResolvConfPath":"/data/docker/containers/9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2/resolv.conf","RestartCount":0,"State":{"Error":"","ExitCode":0,"FinishedAt":"0001-01-01T00:00:00Z","OOMKilled":false,"Paused":false,"Pid":29174,"Restarting":false,"Running":true,"StartedAt":"2015-02-23T19:44:39.19713536Z"},"Volumes":{},"VolumesRW":{}}
101
+ http_version:
102
+ recorded_at: Mon, 23 Feb 2015 19:44:39 GMT
103
+ - request:
104
+ method: post
105
+ uri: "<DOCKER_HOST>/v1.16/containers/9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2/kill"
106
+ body:
107
+ encoding: US-ASCII
108
+ string: ''
109
+ headers:
110
+ User-Agent:
111
+ - Swipely/Docker-API 1.19.0
112
+ Content-Type:
113
+ - text/plain
114
+ response:
115
+ status:
116
+ code: 204
117
+ message:
118
+ headers:
119
+ Date:
120
+ - Mon, 23 Feb 2015 19:44:39 GMT
121
+ body:
122
+ encoding: UTF-8
123
+ string: ''
124
+ http_version:
125
+ recorded_at: Mon, 23 Feb 2015 19:44:39 GMT
126
+ - request:
127
+ method: delete
128
+ uri: "<DOCKER_HOST>/v1.16/containers/9da0d07895abd822be26f56dfebca52628b6ebc4cfa1216b633cca367e5632b2"
129
+ body:
130
+ encoding: US-ASCII
131
+ string: ''
132
+ headers:
133
+ User-Agent:
134
+ - Swipely/Docker-API 1.19.0
135
+ Content-Type:
136
+ - text/plain
137
+ response:
138
+ status:
139
+ code: 204
140
+ message:
141
+ headers:
142
+ Date:
143
+ - Mon, 23 Feb 2015 19:44:39 GMT
144
+ body:
145
+ encoding: UTF-8
146
+ string: ''
147
+ http_version:
148
+ recorded_at: Mon, 23 Feb 2015 19:44:39 GMT
149
+ recorded_with: VCR 2.9.3
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.19.0
4
+ version: 1.20.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: 2015-02-12 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: archive-tar-minitar
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -251,6 +237,7 @@ files:
251
237
  - spec/vcr/Docker_Container/_logs/when_not_selecting_any_stream/raises_a_client_error.yml
252
238
  - spec/vcr/Docker_Container/_logs/when_selecting_stdout/returns_blank_logs.yml
253
239
  - spec/vcr/Docker_Container/_pause/pauses_the_container.yml
240
+ - spec/vcr/Docker_Container/_rename/renames_the_container.yml
254
241
  - spec/vcr/Docker_Container/_restart/restarts_the_container.yml
255
242
  - spec/vcr/Docker_Container/_run/when_the_Container_s_command_does_not_return_status_code_of_0/raises_an_error.yml
256
243
  - spec/vcr/Docker_Container/_run/when_the_Container_s_command_returns_a_status_code_of_0/creates_a_new_container_to_run_the_specified_command.yml
@@ -375,6 +362,7 @@ test_files:
375
362
  - spec/vcr/Docker_Container/_logs/when_not_selecting_any_stream/raises_a_client_error.yml
376
363
  - spec/vcr/Docker_Container/_logs/when_selecting_stdout/returns_blank_logs.yml
377
364
  - spec/vcr/Docker_Container/_pause/pauses_the_container.yml
365
+ - spec/vcr/Docker_Container/_rename/renames_the_container.yml
378
366
  - spec/vcr/Docker_Container/_restart/restarts_the_container.yml
379
367
  - spec/vcr/Docker_Container/_run/when_the_Container_s_command_does_not_return_status_code_of_0/raises_an_error.yml
380
368
  - spec/vcr/Docker_Container/_run/when_the_Container_s_command_returns_a_status_code_of_0/creates_a_new_container_to_run_the_specified_command.yml