docker-api 1.31.0 → 1.32.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: a1d9749b7eea95cde9fd6bf9acf5f0f37417b2d0
4
- data.tar.gz: 75453af3775a005fead451d161c2571cf2efb6d4
3
+ metadata.gz: 24c44afe16ce143e0cb09c157fc490ea3ea9c00f
4
+ data.tar.gz: e5c7f733b034f6bcaed6979e4a134441a8703753
5
5
  SHA512:
6
- metadata.gz: b0850b2386f8a5ab23a5a2c82b562eca9a7e0e2ffb0ced598003f59c91f57ed9c97a5f1f2f35f84f59d240e4763e168e2d9279815138bfaa2d7adb60164f2968
7
- data.tar.gz: 77dbcc8610a471671e087c6f76c1530d664cf8afb76742cc1c86fd16240759f068e47dd21cab1e1a306d1985f39131c38e1e07a4606314aada69ed4f811c74c2
6
+ metadata.gz: 985d465e9b1f8f3a11e192649ceb182c5650eed07c7aac74ae398bd22dde4c640e455f30cb191fb3b1d71e3859750d9edce8ea6a18673e21e1de1f86893065d4
7
+ data.tar.gz: 8dd265004699bf634cc002e4147b1c4af312d829f4b71e7b03c1b7a783321ad277688effa30e26bc2c759f66788f88dbec8e6b5966e2f5ba2213b9a743311dc6
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  docker-api
2
2
  ==========
3
- [![Gem Version](https://badge.fury.io/rb/docker-api.png)](https://badge.fury.io/rb/docker-api) [![travis-ci](https://travis-ci.org/swipely/docker-api.png?branch=master)](https://travis-ci.org/swipely/docker-api) [![Code Climate](https://codeclimate.com/github/swipely/docker-api.png)](https://codeclimate.com/github/swipely/docker-api) [![Dependency Status](https://gemnasium.com/swipely/docker-api.png)](https://gemnasium.com/swipely/docker-api)
3
+ [![Gem Version](https://badge.fury.io/rb/docker-api.svg)](https://badge.fury.io/rb/docker-api) [![travis-ci](https://travis-ci.org/swipely/docker-api.svg?branch=master)](https://travis-ci.org/swipely/docker-api) [![Code Climate](https://codeclimate.com/github/swipely/docker-api.svg)](https://codeclimate.com/github/swipely/docker-api) [![Dependency Status](https://gemnasium.com/swipely/docker-api.svg)](https://gemnasium.com/swipely/docker-api)
4
4
 
5
5
  This gem provides an object-oriented interface to the [Docker Remote API](https://docs.docker.com/reference/api/docker_remote_api/). Every method listed there is implemented. At the time of this writing, docker-api is meant to interface with Docker version 1.3.*
6
6
 
@@ -87,7 +87,7 @@ private
87
87
  }.merge(headers),
88
88
  :expects => (200..204).to_a << 304,
89
89
  :idempotent => http_method == :get,
90
- :request_block => block
90
+ :request_block => block,
91
91
  }.merge(opts).reject { |_, v| v.nil? }
92
92
  end
93
93
  end
@@ -99,7 +99,7 @@ class Docker::Container
99
99
  end
100
100
 
101
101
  # Attach to a container's standard streams / logs.
102
- def attach(options = {}, &block)
102
+ def attach(options = {}, excon_params = {}, &block)
103
103
  stdin = options.delete(:stdin)
104
104
  tty = options.delete(:tty)
105
105
 
@@ -109,8 +109,6 @@ class Docker::Container
109
109
  # Creates list to store stdout and stderr messages
110
110
  msgs = Docker::Messages.new
111
111
 
112
- excon_params = {}
113
-
114
112
  if stdin
115
113
  # If attaching to stdin, we must hijack the underlying TCP connection
116
114
  # so we can stream stdin to the remote Docker process
@@ -211,8 +209,18 @@ class Docker::Container
211
209
  define_method(:"#{method}!") do |opts = {}|
212
210
  timeout = opts.delete('timeout')
213
211
  query = {}
214
- query['t'] = timeout if timeout
215
- connection.post(path_for(method), query, :body => opts.to_json)
212
+ request_options = {
213
+ :body => opts.to_json
214
+ }
215
+ if timeout
216
+ query['t'] = timeout
217
+ # Ensure request does not timeout before Docker timeout
218
+ request_options.merge!(
219
+ read_timeout: timeout.to_i + 5,
220
+ write_timeout: timeout.to_i + 5
221
+ )
222
+ end
223
+ connection.post(path_for(method), query, request_options)
216
224
  self
217
225
  end
218
226
 
@@ -2,10 +2,10 @@
2
2
  class Docker::Network
3
3
  include Docker::Base
4
4
 
5
- def connect(container, opts = {})
5
+ def connect(container, opts = {}, body_opts = {})
6
6
  Docker::Util.parse_json(
7
7
  connection.post(path_for('connect'), opts,
8
- body: { container: container }.to_json)
8
+ body: { container: container }.merge(body_opts).to_json)
9
9
  )
10
10
  reload
11
11
  end
@@ -1,6 +1,9 @@
1
1
  # This module holds shared logic that doesn't really belong anywhere else in the
2
2
  # gem.
3
3
  module Docker::Util
4
+ # http://www.tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm#STANDARD-WILDCARDS
5
+ GLOB_WILDCARDS = /[\?\*\[\{]/
6
+
4
7
  include Docker::Error
5
8
 
6
9
  module_function
@@ -141,7 +144,10 @@ module Docker::Util
141
144
 
142
145
  def create_relative_dir_tar(directory, output)
143
146
  Gem::Package::TarWriter.new(output) do |tar|
144
- Find.find(directory) do |prefixed_file_name|
147
+ files = glob_all_files(File.join(directory, "**/*"))
148
+ remove_ignored_files!(directory, files)
149
+
150
+ files.each do |prefixed_file_name|
145
151
  stat = File.stat(prefixed_file_name)
146
152
  next unless stat.file?
147
153
 
@@ -253,4 +259,22 @@ module Docker::Util
253
259
  'X-Registry-Config' => encoded_header
254
260
  }
255
261
  end
262
+
263
+ def glob_all_files(pattern)
264
+ Dir.glob(pattern, File::FNM_DOTMATCH) - ['..', '.']
265
+ end
266
+
267
+ def remove_ignored_files!(directory, files)
268
+ ignore = File.join(directory, '.dockerignore')
269
+ return unless files.include?(ignore)
270
+ ignored_files(directory, ignore).each { |f| files.delete(f) }
271
+ end
272
+
273
+ def ignored_files(directory, ignore_file)
274
+ patterns = File.read(ignore_file).split("\n").each(&:strip!)
275
+ patterns.reject! { |p| p.empty? || p.start_with?('#') }
276
+ patterns.map! { |p| File.join(directory, p) }
277
+ patterns.map! { |p| File.directory?(p) ? "#{p}/**/*" : p }
278
+ patterns.flat_map { |p| p =~ GLOB_WILDCARDS ? glob_all_files(p) : p }
279
+ end
256
280
  end
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.31.0'
3
+ VERSION = '1.32.0'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.16'
@@ -29,10 +29,9 @@ class Docker::Volume
29
29
  end
30
30
 
31
31
  # creates a volume with an arbitrary name
32
- def create(name, conn = Docker.connection)
33
- query = {}
34
- query['name'] = name if name
35
- resp = conn.post('/volumes/create', query, :body => query.to_json)
32
+ def create(name, opts = {}, conn = Docker.connection)
33
+ opts['Name'] = name
34
+ resp = conn.post('/volumes/create', {}, :body => opts.to_json)
36
35
  hash = Docker::Util.parse_json(resp) || {}
37
36
  new(conn, hash)
38
37
  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.31.0
4
+ version: 1.32.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-08-06 00:00:00.000000000 Z
11
+ date: 2016-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -140,37 +140,24 @@ dependencies:
140
140
  name: parallel
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 1.3.3
145
+ version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: 1.3.3
152
+ version: '0'
153
153
  description: A simple REST client for the Docker Remote API
154
- email:
155
- - tomhulihan@swipely.com
156
- - bright@swipely.com
157
- - toddlunter@swipely.com
154
+ email: tomhulihan@swipely.com bright@swipely.com toddlunter@swipely.com
158
155
  executables: []
159
156
  extensions: []
160
157
  extra_rdoc_files: []
161
158
  files:
162
- - ".cane"
163
- - ".gitignore"
164
- - ".rspec"
165
- - ".simplecov"
166
- - ".travis.yml"
167
- - Dockerfile
168
- - Gemfile
169
159
  - LICENSE
170
160
  - README.md
171
- - Rakefile
172
- - TESTING.md
173
- - docker-api.gemspec
174
161
  - lib/docker-api.rb
175
162
  - lib/docker.rb
176
163
  - lib/docker/base.rb
@@ -188,25 +175,6 @@ files:
188
175
  - lib/docker/version.rb
189
176
  - lib/docker/volume.rb
190
177
  - lib/excon/middlewares/hijack.rb
191
- - script/docker
192
- - script/docker.conf
193
- - script/install_docker.sh
194
- - spec/docker/connection_spec.rb
195
- - spec/docker/container_spec.rb
196
- - spec/docker/event_spec.rb
197
- - spec/docker/exec_spec.rb
198
- - spec/docker/image_spec.rb
199
- - spec/docker/messages_spec.rb
200
- - spec/docker/messages_stack.rb
201
- - spec/docker/network_spec.rb
202
- - spec/docker/util_spec.rb
203
- - spec/docker/volume_spec.rb
204
- - spec/docker_spec.rb
205
- - spec/fixtures/build_from_dir/Dockerfile
206
- - spec/fixtures/export.tar
207
- - spec/fixtures/load.tar
208
- - spec/fixtures/top/Dockerfile
209
- - spec/spec_helper.rb
210
178
  homepage: https://github.com/swipely/docker-api
211
179
  licenses:
212
180
  - MIT
@@ -219,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
187
  requirements:
220
188
  - - ">="
221
189
  - !ruby/object:Gem::Version
222
- version: '0'
190
+ version: 2.0.0
223
191
  required_rubygems_version: !ruby/object:Gem::Requirement
224
192
  requirements:
225
193
  - - ">="
@@ -231,21 +199,5 @@ rubygems_version: 2.4.5
231
199
  signing_key:
232
200
  specification_version: 4
233
201
  summary: A simple REST client for the Docker Remote API
234
- test_files:
235
- - spec/docker/connection_spec.rb
236
- - spec/docker/container_spec.rb
237
- - spec/docker/event_spec.rb
238
- - spec/docker/exec_spec.rb
239
- - spec/docker/image_spec.rb
240
- - spec/docker/messages_spec.rb
241
- - spec/docker/messages_stack.rb
242
- - spec/docker/network_spec.rb
243
- - spec/docker/util_spec.rb
244
- - spec/docker/volume_spec.rb
245
- - spec/docker_spec.rb
246
- - spec/fixtures/build_from_dir/Dockerfile
247
- - spec/fixtures/export.tar
248
- - spec/fixtures/load.tar
249
- - spec/fixtures/top/Dockerfile
250
- - spec/spec_helper.rb
202
+ test_files: []
251
203
  has_rdoc:
data/.cane DELETED
@@ -1,2 +0,0 @@
1
- --abc-max 19
2
- --style-measure 100
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- .DS_Store
2
- *.swp
3
- *.gem
4
- Gemfile.lock
5
- coverage/
6
- .ruby-*
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --order rand
data/.simplecov DELETED
@@ -1,4 +0,0 @@
1
- SimpleCov.start do
2
- add_group 'Library', 'lib'
3
- add_group 'Specs', 'spec'
4
- end
@@ -1,26 +0,0 @@
1
- sudo: required
2
- dist: trusty
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.2
7
- - 2.1
8
- - 2.0
9
- - 1.9.3
10
- env:
11
- - DOCKER_VERSION=1.11.1
12
- - DOCKER_VERSION=1.10.3
13
- - DOCKER_VERSION=1.9.1
14
- - DOCKER_VERSION=1.8.2
15
- - DOCKER_VERSION=1.7.1
16
- - DOCKER_VERSION=1.6.2
17
- matrix:
18
- fast_finish: true
19
- before_install:
20
- - docker --version
21
- - gem install bundler
22
- before_script:
23
- - sudo ./script/install_docker.sh ${DOCKER_VERSION}
24
- - uname -a
25
- - docker --version
26
- - docker info
data/Dockerfile DELETED
@@ -1,2 +0,0 @@
1
- FROM scratch
2
- ADD Dockerfile /Dockerfile
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,54 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
- ENV['PATH'] = "/opt/docker/:#{ENV['PATH']}" if ENV['CI'] == 'true'
3
-
4
- require 'rake'
5
- require 'docker'
6
- require 'rspec/core/rake_task'
7
- require 'cane/rake_task'
8
-
9
-
10
- desc 'Run the full test suite from scratch'
11
- task :default => [:unpack, :rspec, :quality]
12
-
13
- RSpec::Core::RakeTask.new do |t|
14
- t.pattern = 'spec/**/*_spec.rb'
15
- end
16
-
17
- Cane::RakeTask.new(:quality) do |cane|
18
- cane.canefile = '.cane'
19
- end
20
-
21
- desc 'Download the necessary base images'
22
- task :unpack do
23
- %w( swipely/base registry busybox tianon/true debian:wheezy ).each do |image|
24
- system "docker pull #{image}"
25
- end
26
- end
27
-
28
- desc 'Run spec tests with a registry'
29
- task :rspec do
30
- begin
31
- registry = Docker::Container.create(
32
- 'name' => 'registry',
33
- 'Image' => 'registry',
34
- 'Env' => ["GUNICORN_OPTS=[--preload]"],
35
- 'ExposedPorts' => {
36
- '5000/tcp' => {}
37
- },
38
- 'HostConfig' => {
39
- 'PortBindings' => { '5000/tcp' => [{ 'HostPort' => '5000' }] }
40
- }
41
- )
42
- registry.start
43
- Rake::Task["spec"].invoke
44
- ensure
45
- registry.kill!.remove unless registry.nil?
46
- end
47
- end
48
-
49
- desc 'Pull an Ubuntu image'
50
- image 'ubuntu:13.10' do
51
- puts "Pulling ubuntu:13.10"
52
- image = Docker::Image.create('fromImage' => 'ubuntu', 'tag' => '13.10')
53
- puts "Pulled ubuntu:13.10, image id: #{image.id}"
54
- end
data/TESTING.md DELETED
@@ -1,49 +0,0 @@
1
- # Prerequisites
2
- To develop on this gem, you must the following installed:
3
- * a sane Ruby 1.9+ environment with `bundler`
4
- ```shell
5
- $ gem install bundler
6
- ```
7
- * Docker v1.3.1 or greater
8
-
9
-
10
-
11
- # Getting Started
12
- 1. Clone the git repository from Github:
13
- ```shell
14
- $ git clone git@github.com:swipely/docker-api.git
15
- ```
16
- 2. Install the dependencies using Bundler
17
- ```shell
18
- $ bundle install
19
- ```
20
- 3. Create a branch for your changes
21
- ```shell
22
- $ git checkout -b my_bug_fix
23
- ```
24
- 4. Make any changes
25
- 5. Write tests to support those changes.
26
- 6. Run the tests:
27
- * `bundle exec rake`
28
- 7. Assuming the tests pass, open a Pull Request on Github.
29
-
30
- # Using Rakefile Commands
31
- This repository comes with five Rake commands to assist in your testing of the code.
32
-
33
- ## `rake rspec`
34
- This command will run Rspec tests normally on your local system. You must have all the required base images pulled.
35
-
36
- ## `rake quality`
37
- This command runs a code quality threshold checker to hinder bad code.
38
-
39
- ## `rake unpack`
40
- Pulls down all the required base images for testing.
41
-
42
- ### Setting Up Environment Variables
43
- Certain Rspec tests will require your credentials to the Docker Hub. If you do not have a Docker Hub account, you can sign up for one [here](https://hub.docker.com/account/signup/). To avoid hard-coding credentials into the code the test suite leverages three Environment Variables: `DOCKER_API_USER`, `DOCKER_API_PASS`, and `DOCKER_API_EMAIL`. You will need to configure your work environment (shell profile, IDE, etc) with these values in order to successfully run certain tests.
44
-
45
- ```shell
46
- export DOCKER_API_USER='your_docker_hub_user'
47
- export DOCKER_API_PASS='your_docker_hub_password'
48
- export DOCKER_API_EMAIL='your_docker_hub_email_address'
49
- ```
@@ -1,28 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/docker/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["Swipely, Inc."]
6
- gem.email = %w{tomhulihan@swipely.com bright@swipely.com toddlunter@swipely.com}
7
- gem.description = %q{A simple REST client for the Docker Remote API}
8
- gem.summary = %q{A simple REST client for the Docker Remote API}
9
- gem.homepage = 'https://github.com/swipely/docker-api'
10
- gem.license = 'MIT'
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "docker-api"
15
- gem.require_paths = %w{lib}
16
- gem.version = Docker::VERSION
17
- gem.add_dependency 'excon', '>= 0.38.0'
18
- gem.add_dependency 'json'
19
- gem.add_development_dependency 'rake'
20
- gem.add_development_dependency 'rspec', '~> 3.0'
21
- gem.add_development_dependency 'rspec-its'
22
- gem.add_development_dependency 'cane'
23
- gem.add_development_dependency 'pry'
24
- gem.add_development_dependency 'simplecov'
25
- gem.add_development_dependency 'webmock'
26
- # > 1.3.4 doesn't support ruby 1.9.2
27
- gem.add_development_dependency 'parallel', '1.3.3'
28
- end