dockerapi 0.20.0 → 0.21.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dae8acdc54de9fd88a68b472829ddef47db3884414ded58ad098babd4a786c58
4
- data.tar.gz: 4828f010ed6a3e32ee80d2e9e11ef68ef1375df988928a3d5c856aaa2791a7ed
3
+ metadata.gz: f437d91a99a54403c5f945d2f9814d21cdf4ddde861a9aa6a0cb5fc8733407db
4
+ data.tar.gz: d80832f6576d633db58dc546496604fa30b94e4f1dd3020cfabcd61df538ec99
5
5
  SHA512:
6
- metadata.gz: d30c788f83b0cfc1e88bf1441a7b48037820573f4817490e490cf6811e07b88baf67fe52f68418ffc80213631364db61f2739bf40ea50f90617ef9a2da3a322d
7
- data.tar.gz: 623f2a33c84a423bd8ee38a5b98a62e8ccb04f6212d03a07c18005b501b812e88d2bfd03de384965ccb857aba53f539516b93e37885c547779ea20db08376bda
6
+ metadata.gz: 2620eb13fad97f0f6529db6f3d6501351790e1d6ca90200c24ed7aef34db1179d3e6c8f6cb4d780dc046c0bc6a45c0ed23f2dff75f336ddfd6c17c33e699ee2a
7
+ data.tar.gz: 8b757f7abb03f9fe449caadc09407beac250a9c605ed493e6aabdae2be0471666003ffb9f58fb67fba42fcc201b549b803748a0089865086abd7c3262f3a1898
@@ -1,7 +1,8 @@
1
1
  name: CD
2
2
  on:
3
3
  push:
4
- branches: [ main ]
4
+ tags:
5
+ - 'v*.*.*'
5
6
 
6
7
  jobs:
7
8
  release:
@@ -12,9 +13,9 @@ jobs:
12
13
  steps:
13
14
  - uses: actions/checkout@v3
14
15
  - name: Set up Ruby
15
- uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a
16
+ uses: ruby/setup-ruby@v1
16
17
  with:
17
- ruby-version: 2.6
18
+ ruby-version: 3.3
18
19
  - name: Setup to RubyGems
19
20
  run: |
20
21
  mkdir -p $HOME/.gem
@@ -23,13 +24,11 @@ jobs:
23
24
  printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
24
25
  - name: Install dependencies
25
26
  run: |
26
- gem update --system 3.2.3
27
+ gem update --system 3.5.11
27
28
  bundle install
28
29
  - name: Release
29
30
  run: |
30
31
  TAG=$(bundle exec rake version | tr -d '"')
31
- git tag $TAG
32
- git push --tags
33
32
  gh release create $TAG --generate-notes
34
33
  bundle exec rake build
35
34
  gem push pkg/*
@@ -10,44 +10,12 @@ jobs:
10
10
  steps:
11
11
  - uses: actions/checkout@v2
12
12
  - name: Set up Ruby
13
- uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a
13
+ uses: ruby/setup-ruby@v1
14
14
  with:
15
- ruby-version: 2.6
16
- - name: Install Docker
17
- run: curl https://get.docker.com | sh
15
+ ruby-version: 3.3
18
16
  - name: Install dependencies
19
- run: |
20
- bin/setup
21
- sudo bin/setup
22
- - name: Test misc
23
- run: rspec spec/misc/*.rb
24
- - name: Test Image
25
- run: rspec spec/endpoints/image_spec.rb:1
26
- - name: Test Image authentication
27
- run: rspec spec/endpoints/image_spec.rb:196
28
- continue-on-error: true
29
- - name: Test Container
30
- run: rspec spec/endpoints/container_spec.rb
31
- - name: Test Volume
32
- run: rspec spec/endpoints/volume_spec.rb
33
- - name: Test Network
34
- run: rspec spec/endpoints/network_spec.rb
35
- - name: Test System
36
- run: rspec spec/endpoints/system_spec.rb
37
- - name: Test Exec
38
- run: rspec spec/endpoints/exec_spec.rb
39
- - name: Test Swarm
40
- run: rspec spec/endpoints/swarm_spec.rb
41
- - name: Test Node
42
- run: rspec spec/endpoints/node_spec.rb
43
- - name: Test Service
44
- run: rspec spec/endpoints/service_spec.rb
45
- - name: Test Task
46
- run: rspec spec/endpoints/task_spec.rb
47
- - name: Test Secret
48
- run: rspec spec/endpoints/secret_spec.rb
49
- - name: Test Config
50
- run: rspec spec/endpoints/config_spec.rb
51
- - name: Test Plugin
52
- run: rspec spec/endpoints/plugin_spec.rb
53
-
17
+ run: bundle install
18
+ - name: Run unit tests
19
+ run: rspec
20
+ - name: Run E2E tests
21
+ run: rspec --tag e2e
data/Gemfile CHANGED
@@ -3,5 +3,5 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in dockerapi.gemspec
4
4
  gemspec
5
5
 
6
- gem "rake", "~> 12.0"
6
+ gem "rake", "~> 13.0"
7
7
  gem "rspec", "~> 3.0"
data/Gemfile.lock CHANGED
@@ -1,36 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dockerapi (0.20.0)
5
- excon (~> 0.79)
4
+ dockerapi (0.21.0)
5
+ base64
6
+ excon (>= 0.97, < 2)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- diff-lcs (1.3)
11
- excon (0.79.0)
12
- rake (12.3.3)
13
- rspec (3.9.0)
14
- rspec-core (~> 3.9.0)
15
- rspec-expectations (~> 3.9.0)
16
- rspec-mocks (~> 3.9.0)
17
- rspec-core (3.9.2)
18
- rspec-support (~> 3.9.3)
19
- rspec-expectations (3.9.2)
11
+ base64 (0.2.0)
12
+ diff-lcs (1.5.1)
13
+ excon (1.1.1)
14
+ rake (13.2.1)
15
+ rspec (3.13.0)
16
+ rspec-core (~> 3.13.0)
17
+ rspec-expectations (~> 3.13.0)
18
+ rspec-mocks (~> 3.13.0)
19
+ rspec-core (3.13.2)
20
+ rspec-support (~> 3.13.0)
21
+ rspec-expectations (3.13.3)
20
22
  diff-lcs (>= 1.2.0, < 2.0)
21
- rspec-support (~> 3.9.0)
22
- rspec-mocks (3.9.1)
23
+ rspec-support (~> 3.13.0)
24
+ rspec-mocks (3.13.2)
23
25
  diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.9.0)
25
- rspec-support (3.9.3)
26
+ rspec-support (~> 3.13.0)
27
+ rspec-support (3.13.1)
26
28
 
27
29
  PLATFORMS
30
+ arm64-darwin-23
28
31
  ruby
29
32
 
30
33
  DEPENDENCIES
31
34
  dockerapi!
32
- rake (~> 12.0)
35
+ rake (~> 13.0)
33
36
  rspec (~> 3.0)
34
37
 
35
38
  BUNDLED WITH
36
- 2.4.16
39
+ 2.5.11
data/README.md CHANGED
@@ -143,6 +143,29 @@ container = Docker::API::Container.new
143
143
  # Create container
144
144
  container.create( {name: "nginx"}, {Image: "nginx:latest", HostConfig: {PortBindings: {"80/tcp": [ {HostIp: "0.0.0.0", HostPort: "80"} ]}}})
145
145
 
146
+ # A more complex container creation
147
+ container.create(
148
+ {name: "nginx"},
149
+ {
150
+ Image: "nginx:latest",
151
+ HostConfig: {
152
+ PortBindings: {
153
+ "80/tcp": [ {HostIp: "0.0.0.0", HostPort: "80"} ]
154
+ }
155
+ },
156
+ Env: ["DOCKER=nice", "DOCKERAPI=awesome"],
157
+ Cmd: ["echo", "hello from test"],
158
+ Entrypoint: ["sh"],
159
+ NetworkingConfig: {
160
+ EndpointsConfig: {
161
+ EndpointSettings: {
162
+ IPAddress: "192.172.0.100"
163
+ }
164
+ }
165
+ }
166
+ }
167
+ )
168
+
146
169
  # Start container
147
170
  container.start("nginx")
148
171
 
@@ -529,12 +552,6 @@ response.success?
529
552
  => true
530
553
  ```
531
554
 
532
- ### Error handling
533
-
534
- `Docker::API::InvalidParameter` and `Docker::API::InvalidRequestBody` may be raised when an invalid option is passed as argument (ie: an option not described in Docker API documentation for request query parameters nor request body (json) parameters). Even if no errors were raised, consider validating the status code and/or message of the response to check if the Docker daemon has fulfilled the operation properly.
535
-
536
- To completely skip the validation process, add `:skip_validation => true` in the hash to be validated.
537
-
538
555
  ### Blocks
539
556
 
540
557
  Some methods can receive a block to alter the default execution:
@@ -563,13 +580,14 @@ The default blocks can be found in `Docker::API::Base`.
563
580
 
564
581
  ## Development
565
582
 
566
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
583
+ Run `rspec` to run the unit tests. Run `rspec --tag e2e` to run End-to-End tests (requires Docker locally).
584
+
585
+ Run `bin/console` for an interactive prompt that will allow you to experiment.
567
586
 
568
587
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
569
588
 
570
589
  ### Release new version
571
590
 
572
- * Update CHANGELOG.
573
591
  * Update README as needed.
574
592
  * Update version.
575
593
  * Run tests.
data/dockerapi.gemspec CHANGED
@@ -10,11 +10,10 @@ Gem::Specification.new do |spec|
10
10
  spec.description = "Interact with Docker API directly from Ruby code. Comprehensive implementation (all available endpoints), no local Docker installation required, easily manipulated http responses."
11
11
  spec.homepage = "https://github.com/nu12/dockerapi"
12
12
  spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+ spec.required_ruby_version = ">= 3.2"
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
16
  spec.metadata["source_code_uri"] = "https://github.com/nu12/dockerapi.git"
17
- spec.metadata["changelog_uri"] = "https://github.com/nu12/dockerapi/blob/master/CHANGELOG.md"
18
17
  spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/dockerapi"
19
18
 
20
19
  # Specify which files should be added to the gem when it is released.
@@ -26,5 +25,6 @@ Gem::Specification.new do |spec|
26
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
26
  spec.require_paths = ["lib"]
28
27
 
29
- spec.add_dependency("excon", "~> 0.79")
28
+ spec.add_dependency("base64")
29
+ spec.add_dependency("excon", ">= 0.97", "< 2")
30
30
  end
@@ -7,9 +7,8 @@ class Docker::API::Base
7
7
  #
8
8
  # @param connection [Docker::API::Connection]: Connection to be used.
9
9
  def initialize connection = nil
10
- raise Docker::API::Error.new("Expected connection to be a Docker::API::Connection class") if connection != nil && !connection.is_a?(Docker::API::Connection)
10
+ raise StandardError.new("Expected connection to be a Docker::API::Connection class") if connection != nil && !connection.is_a?(Docker::API::Connection)
11
11
  @connection = connection || Docker::API::Connection.new
12
- set_automated_validation
13
12
  end
14
13
 
15
14
  private
@@ -18,7 +17,7 @@ class Docker::API::Base
18
17
  # Output to stdout.
19
18
  def default_streamer
20
19
  streamer = lambda do |chunk, remaining_bytes, total_bytes|
21
- p chunk.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') if Docker::API::PRINT_TO_STDOUT
20
+ p chunk.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') if Docker::API.print_to_stdout
22
21
  end
23
22
  streamer
24
23
  end
@@ -59,18 +58,6 @@ class Docker::API::Base
59
58
  Base64.urlsafe_encode64(authentication.to_json.to_s).chomp
60
59
  end
61
60
 
62
- ##
63
- # Validate a Hash object comparing its keys with a given Array of permitted values. Raise an error if the validation fail.
64
- #
65
- # @param error [Error]: Error to be raised of the validation fail.
66
- # @param permitted [Array]: List of permitted keys.
67
- # @param params [Hash]: Hash object to be validated.
68
- def validate error, permitted, params
69
- return if params[:skip_validation]
70
- unpermitted = params.keys.map(&:to_s) - permitted.map(&:to_s)
71
- raise error.new(permitted, unpermitted) if unpermitted.size > 0
72
- end
73
-
74
61
  ##
75
62
  # Convert Ruby Hash into URL query parameters.
76
63
  #
@@ -79,7 +66,7 @@ class Docker::API::Base
79
66
  # @param hash [Hash]: Hash object to be converted in a query parameter-like string.
80
67
  def hash_to_params hash
81
68
  p = []
82
- hash.delete_if{ | k, v | k.to_s == "skip_validation" }.each { |k,v| p.push( v.is_a?(Hash) ? "#{k}=#{v.to_json}" : "#{k}=#{v}") }
69
+ hash.each { |k,v| p.push( v.is_a?(Hash) ? "#{k}=#{v.to_json}" : "#{k}=#{v}") }
83
70
  p.join("&").gsub(" ","")
84
71
  end
85
72
 
@@ -89,22 +76,8 @@ class Docker::API::Base
89
76
  # @param path [String]: Base URL string.
90
77
  # @param hash [Hash]: Hash object to be appended to the URL as query parameters.
91
78
  def build_path path, params = {}
79
+ path = "/v#{Docker::API::API_VERSION}#{path}"
92
80
  params.size > 0 ? [path, hash_to_params(params)].join("?") : path
93
81
  end
94
82
 
95
- ##
96
- # Set the validation to happen automatically when method parameters include "params" or "body".
97
- def set_automated_validation
98
- (self.methods - Object.methods).each do |method|
99
- params_index = method(method).parameters.map{|ar| ar[1]}.index(:params)
100
- body_index = method(method).parameters.map{|ar| ar[1]}.index(:body)
101
-
102
- define_singleton_method(method) do |*args, &block|
103
- validate Docker::API::InvalidParameter, Docker::API::VALID_PARAMS["#{self.class.name}"]["#{method}"], (args[params_index] || {}) if params_index
104
- validate Docker::API::InvalidRequestBody, Docker::API::VALID_BODY["#{self.class.name}"]["#{method}"], (args[body_index] || {}) if body_index
105
- super(*args,&block)
106
- end
107
- end
108
- end
109
-
110
83
  end
@@ -24,7 +24,7 @@ class Docker::API::Config < Docker::API::Base
24
24
  #
25
25
  # @param body [Hash]: Request body to be sent as json.
26
26
  def create body = {}
27
- @connection.request(method: :post, path: "/configs/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
27
+ @connection.request(method: :post, path: "/v#{Docker::API::API_VERSION}/configs/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
28
28
  end
29
29
 
30
30
  # Inspect a config
@@ -35,7 +35,7 @@ class Docker::API::Config < Docker::API::Base
35
35
  #
36
36
  # @param name [String]: The ID or name of the config.
37
37
  def details name
38
- @connection.get("/configs/#{name}")
38
+ @connection.get("/v#{Docker::API::API_VERSION}/configs/#{name}")
39
39
  end
40
40
 
41
41
  # Update a config
@@ -50,7 +50,7 @@ class Docker::API::Config < Docker::API::Base
50
50
  #
51
51
  # @param body [Hash]: Request body to be sent as json.
52
52
  def update name, params = {}, body = {}
53
- @connection.request(method: :post, path: build_path("/configs/#{name}/update",params), headers: {"Content-Type": "application/json"}, body: body.to_json)
53
+ @connection.request(method: :post, path: build_path("/v#{Docker::API::API_VERSION}/configs/#{name}/update",params), headers: {"Content-Type": "application/json"}, body: body.to_json)
54
54
  end
55
55
 
56
56
  # Delete a config
@@ -61,6 +61,6 @@ class Docker::API::Config < Docker::API::Base
61
61
  #
62
62
  # @param name [String]: The ID or name of the config.
63
63
  def delete name
64
- @connection.delete("/configs/#{name}")
64
+ @connection.delete("/v#{Docker::API::API_VERSION}/configs/#{name}")
65
65
  end
66
66
  end
@@ -11,7 +11,8 @@ class Docker::API::Connection
11
11
  # @param params [Hash]: Request parameters.
12
12
  def request params
13
13
  response = Docker::API::Response.new(@connection.request(params).data)
14
- p response if Docker::API::PRINT_RESPONSE_TO_STDOUT
14
+ response.request_params = params
15
+ p response if Docker::API.print_response_to_stdout
15
16
  response
16
17
  end
17
18
 
@@ -20,9 +21,9 @@ class Docker::API::Connection
20
21
  #
21
22
  # @param url [String]: URL for the connection.
22
23
  # @param params [String]: Additional parameters.
23
- def initialize url = nil, params = nil
24
- return @connection = Excon.new('unix:///', {socket: '/var/run/docker.sock'}) unless url
25
- @connection = Excon.new(url, params || {})
24
+ def initialize url = nil, params = {}
25
+ return @connection = Excon.new('unix:///', params.merge({socket: '/var/run/docker.sock'})) unless url
26
+ @connection = Excon.new(url, params)
26
27
  end
27
28
 
28
29
  end
@@ -46,7 +46,7 @@ class Docker::API::Container < Docker::API::Base
46
46
  #
47
47
  # @param name [String]: The ID or name of the container.
48
48
  def changes name
49
- @connection.get("/containers/#{name}/changes")
49
+ @connection.get(build_path("/containers/#{name}/changes"))
50
50
  end
51
51
 
52
52
  ##
@@ -118,7 +118,8 @@ class Docker::API::Container < Docker::API::Base
118
118
  # @param name [String]: The ID or name of the container.
119
119
  # @param body [Hash]: Request body to be sent as json.
120
120
  def update name, body = {}
121
- @connection.request(method: :post, path: "/containers/#{name}/update", headers: {"Content-Type": "application/json"}, body: body.to_json)
121
+
122
+ @connection.request(method: :post, path: build_path("/containers/#{name}/update"), headers: {"Content-Type": "application/json"}, body: body.to_json)
122
123
  end
123
124
 
124
125
  ##
@@ -164,7 +165,7 @@ class Docker::API::Container < Docker::API::Base
164
165
  #
165
166
  # @param name [String]: The ID or name of the container.
166
167
  def pause name
167
- @connection.post("/containers/#{name}/pause")
168
+ @connection.post(build_path("/containers/#{name}/pause"))
168
169
  end
169
170
 
170
171
  ##
@@ -175,7 +176,7 @@ class Docker::API::Container < Docker::API::Base
175
176
  #
176
177
  # @param name [String]: The ID or name of the container.
177
178
  def unpause name
178
- @connection.post("/containers/#{name}/unpause")
179
+ @connection.post(build_path("/containers/#{name}/unpause"))
179
180
  end
180
181
 
181
182
  ##
@@ -12,7 +12,7 @@ class Docker::API::Exec < Docker::API::Base
12
12
  # @param name [String]: The ID or name of the container.
13
13
  # @param body [Hash]: Request body to be sent as json.
14
14
  def create name, body = {}
15
- @connection.request(method: :post, path: "/containers/#{name}/exec", headers: {"Content-Type": "application/json"}, body: body.to_json )
15
+ @connection.request(method: :post, path: build_path("/containers/#{name}/exec"), headers: {"Content-Type": "application/json"}, body: body.to_json )
16
16
  end
17
17
 
18
18
  ##
@@ -25,7 +25,7 @@ class Docker::API::Exec < Docker::API::Base
25
25
  # @param body [Hash]: Request body to be sent as json.
26
26
  # @param &block: Replace the default output to stdout behavior.
27
27
  def start name, body = {}, &block
28
- @connection.request(method: :post, path: "/exec/#{name}/start", headers: {"Content-Type": "application/json"}, body: body.to_json,
28
+ @connection.request(method: :post, path: build_path("/exec/#{name}/start"), headers: {"Content-Type": "application/json"}, body: body.to_json,
29
29
  response_block: block_given? ? block : default_streamer )
30
30
  end
31
31
 
@@ -49,7 +49,7 @@ class Docker::API::Exec < Docker::API::Base
49
49
  #
50
50
  # @param name [String]: Exec instance ID.
51
51
  def details name
52
- @connection.get("/exec/#{name}/json")
52
+ @connection.get(build_path("/exec/#{name}/json"))
53
53
  end
54
54
 
55
55
  end
@@ -11,7 +11,7 @@ class Docker::API::Image < Docker::API::Base
11
11
  #
12
12
  # @param name [String]: The ID or name of the image.
13
13
  def details name
14
- @connection.get("/images/#{name}/json")
14
+ @connection.get(build_path("/images/#{name}/json"))
15
15
  end
16
16
 
17
17
  ##
@@ -23,7 +23,7 @@ class Docker::API::Image < Docker::API::Base
23
23
  # @param name [String]: The ID or name of the image.
24
24
  # @param authentication [Hash]: Authentication parameters.
25
25
  def distribution name, authentication = {}
26
- request = {method: :get, path: "/distribution/#{name}/json"}
26
+ request = {method: :get, path: build_path("/distribution/#{name}/json")}
27
27
  request[:headers] = {"X-Registry-Auth" => auth_encoder(authentication)} if authentication.any?
28
28
  @connection.request(request)
29
29
  end
@@ -36,7 +36,7 @@ class Docker::API::Image < Docker::API::Base
36
36
  #
37
37
  # @param name [String]: The ID or name of the image.
38
38
  def history name
39
- @connection.get("/images/#{name}/history")
39
+ @connection.get(build_path("/images/#{name}/history"))
40
40
  end
41
41
 
42
42
  ##
@@ -133,7 +133,7 @@ class Docker::API::Image < Docker::API::Base
133
133
  # @param params [Hash]: Parameters that are appended to the URL.
134
134
  # @param authentication [Hash]: Authentication parameters.
135
135
  def push name, params = {}, authentication = {}
136
- raise Docker::API::Error.new("Provide authentication parameters to push an image") unless authentication.any?
136
+ raise StandardError.new("Provide authentication parameters to push an image") unless authentication.any?
137
137
  @connection.request(method: :post, path: build_path("/images/#{name}/push", params), headers: { "X-Registry-Auth" => auth_encoder(authentication) } )
138
138
  end
139
139
 
@@ -146,7 +146,7 @@ class Docker::API::Image < Docker::API::Base
146
146
  # @param params [Hash]: Parameters that are appended to the URL.
147
147
  # @param body [Hash]: Request body to be sent as json.
148
148
  def commit params = {}, body = {}
149
- container = Docker::API::Container.new.details(params[:container])
149
+ container = Docker::API::Container.new(@connection).details(params[:container])
150
150
  return container if [404, 301].include? container.status
151
151
  @connection.request(method: :post, path: build_path("/commit", params), headers: {"Content-Type": "application/json"}, body: container.json["Config"].merge(body).to_json)
152
152
  end
@@ -185,7 +185,7 @@ class Docker::API::Image < Docker::API::Base
185
185
  def build path, params = {}, authentication = {}, &block
186
186
  raise Docker::API::Error.new("Expected path or params[:remote]") unless path || params[:remote]
187
187
 
188
- headers = {"Content-type": "application/x-tar"}
188
+ headers = {"Content-type" => "application/x-tar"}
189
189
  headers.merge!({"X-Registry-Config": auth_encoder(authentication) }) if authentication.any?
190
190
 
191
191
  if path == nil and params.has_key? :remote
@@ -34,7 +34,7 @@ class Docker::API::Network < Docker::API::Base
34
34
  #
35
35
  # @param body [Hash]: Request body to be sent as json.
36
36
  def create body = {}
37
- @connection.request(method: :post, path: "/networks/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
37
+ @connection.request(method: :post, path: build_path("/networks/create"), headers: {"Content-Type" => "application/json"}, body: body.to_json)
38
38
  end
39
39
 
40
40
  ##
@@ -45,7 +45,7 @@ class Docker::API::Network < Docker::API::Base
45
45
  #
46
46
  # @param name [String]: The ID or name of the network.
47
47
  def remove name
48
- @connection.delete("/networks/#{name}")
48
+ @connection.delete(build_path("/networks/#{name}"))
49
49
  end
50
50
 
51
51
  ##
@@ -68,7 +68,7 @@ class Docker::API::Network < Docker::API::Base
68
68
  # @param name [String]: The ID or name of the network.
69
69
  # @param body [Hash]: Request body to be sent as json.
70
70
  def connect name, body = {}
71
- @connection.request(method: :post, path: "/networks/#{name}/connect", headers: {"Content-Type": "application/json"}, body: body.to_json)
71
+ @connection.request(method: :post, path: build_path("/networks/#{name}/connect"), headers: {"Content-Type" => "application/json"}, body: body.to_json)
72
72
  end
73
73
 
74
74
  ##
@@ -80,7 +80,7 @@ class Docker::API::Network < Docker::API::Base
80
80
  # @param name [String]: The ID or name of the network.
81
81
  # @param body [Hash]: Request body to be sent as json.
82
82
  def disconnect name, body = {}
83
- @connection.request(method: :post, path: "/networks/#{name}/disconnect", headers: {"Content-Type": "application/json"}, body: body.to_json)
83
+ @connection.request(method: :post, path: build_path("/networks/#{name}/disconnect"), headers: {"Content-Type" => "application/json"}, body: body.to_json)
84
84
  end
85
85
 
86
86
  end
@@ -25,7 +25,7 @@ class Docker::API::Node < Docker::API::Base
25
25
  # @param params [Hash]: Parameters that are appended to the URL.
26
26
  # @param body [Hash]: Request body to be sent as json.
27
27
  def update name, params = {}, body = {}
28
- @connection.request(method: :post, path: build_path("nodes/#{name}/update", params), headers: {"Content-Type": "application/json"}, body: body.to_json)
28
+ @connection.request(method: :post, path: build_path("/nodes/#{name}/update", params), headers: {"Content-Type" => "application/json"}, body: body.to_json)
29
29
  end
30
30
 
31
31
  ##
@@ -48,6 +48,6 @@ class Docker::API::Node < Docker::API::Base
48
48
  #
49
49
  # @param name [String]: The ID or name of the node.
50
50
  def details name
51
- @connection.get("/nodes/#{name}")
51
+ @connection.get(build_path("/nodes/#{name}"))
52
52
  end
53
53
  end
@@ -39,7 +39,7 @@ class Docker::API::Plugin < Docker::API::Base
39
39
  #
40
40
  # @param authentication [Hash]: Authentication parameters.
41
41
  def install params = {}, privileges = [], authentication = {}
42
- headers = {"Content-Type": "application/json"}
42
+ headers = {"Content-Type" => "application/json"}
43
43
  headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
44
44
  @connection.request(method: :post, path: build_path("/plugins/pull", params), headers: headers, body: privileges.to_json )
45
45
  end
@@ -52,7 +52,7 @@ class Docker::API::Plugin < Docker::API::Base
52
52
  #
53
53
  # @param name [String]: The ID or name of the plugin.
54
54
  def details name
55
- @connection.get("/plugins/#{name}/json")
55
+ @connection.get(build_path("/plugins/#{name}/json"))
56
56
  end
57
57
 
58
58
  # Remove a plugin
@@ -89,7 +89,7 @@ class Docker::API::Plugin < Docker::API::Base
89
89
  #
90
90
  # @param name [String]: The ID or name of the plugin.
91
91
  def disable name
92
- @connection.post("/plugins/#{name}/disable")
92
+ @connection.post(build_path("/plugins/#{name}/disable"))
93
93
  end
94
94
 
95
95
  # Upgrade a plugin
@@ -106,7 +106,7 @@ class Docker::API::Plugin < Docker::API::Base
106
106
  #
107
107
  # @param authentication [Hash]: Authentication parameters.
108
108
  def upgrade name, params = {}, privileges = [], authentication = {}
109
- headers = {"Content-Type": "application/json"}
109
+ headers = {"Content-Type" => "application/json"}
110
110
  headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
111
111
  @connection.request(method: :post, path: build_path("/plugins/#{name}/upgrade", params), headers: headers, body: privileges.to_json )
112
112
  end
@@ -122,7 +122,7 @@ class Docker::API::Plugin < Docker::API::Base
122
122
  # @param path [String]: Path to tar file that contains rootfs folder and config.json file.
123
123
  def create name, path
124
124
  file = File.open( File.expand_path( path ) , "r")
125
- response = @connection.request(method: :post, path: "/plugins/create?name=#{name}", body: file.read.to_s )
125
+ response = @connection.request(method: :post, path: build_path("/plugins/create?name=#{name}"), body: file.read.to_s )
126
126
  file.close
127
127
  response
128
128
  end
@@ -138,9 +138,9 @@ class Docker::API::Plugin < Docker::API::Base
138
138
  # @param authentication [Hash]: Authentication parameters.
139
139
  def push name, authentication = {}
140
140
  if authentication.keys.size > 0
141
- @connection.request(method: :post, path: "/plugins/#{name}/push", headers: {"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)})
141
+ @connection.request(method: :post, path: build_path("/plugins/#{name}/push"), headers: {"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)})
142
142
  else
143
- @connection.post("/plugins/#{name}/push")
143
+ @connection.post(build_path("/plugins/#{name}/push"))
144
144
  end
145
145
  end
146
146
 
@@ -154,7 +154,7 @@ class Docker::API::Plugin < Docker::API::Base
154
154
  #
155
155
  # @param config [Array]: Plugin configuration to be sent as json in request body.
156
156
  def configure name, config
157
- @connection.request(method: :post, path: "/plugins/#{name}/set", headers: {"Content-Type": "application/json"}, body:config.to_json)
157
+ @connection.request(method: :post, path: build_path("/plugins/#{name}/set"), headers: {"Content-Type" => "application/json"}, body:config.to_json)
158
158
  end
159
159
 
160
160
  end
@@ -2,6 +2,7 @@
2
2
  # Reponse class.
3
3
  class Docker::API::Response < Excon::Response
4
4
  attr_reader(:json, :path)
5
+ attr_accessor(:request_params)
5
6
 
6
7
  ##
7
8
  # Initialize a new Response object.