dockerapi 0.22.1 → 1.0.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +26 -0
- data/Rakefile +1 -1
- data/dockerapi.gemspec +1 -1
- data/lib/docker/api/base.rb +4 -1
- data/lib/docker/api/version.rb +1 -5
- data/lib/dockerapi.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1676c69bedabf93f4da697ee177428beb48232ba36977a6b2f92cc5f411881ae
|
4
|
+
data.tar.gz: 4d3af8188af0d79e451917ee57d0e6a05bcc47a472ee4dff6336e6a2a4ab999d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1f784635089efd4bb31c0e93002b3c363c856420e827ad4fc790c855fa3095cc281c4cb663d8207f5614651c95c1069eb2cadc4316fc609464d0edae2e8c493
|
7
|
+
data.tar.gz: e1826a2e006cddc84b7a09da79b8c6fbbec6d0e0961d5405a0e7e77d8da0808826edc9c7629777c7e91794e45b0a8ed8ff387673f73312f5ed27fa8c4a99b02c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,7 @@ Interact with Docker API directly from Ruby code. Comprehensive implementation (
|
|
4
4
|
|
5
5
|
* [Installation](#installation)
|
6
6
|
* [Usage](#usage)
|
7
|
+
* [API version](#api-version)
|
7
8
|
* [Images](#images)
|
8
9
|
* [Containers](#containers)
|
9
10
|
* [Volumes](#volumes)
|
@@ -52,6 +53,31 @@ If you need more information about the different Docker API endpoints, please se
|
|
52
53
|
|
53
54
|
For a more detailed and comprehensive documentation about this gem's API, please see the [documentation page](https://rubydoc.info/gems/dockerapi).
|
54
55
|
|
56
|
+
### API version
|
57
|
+
|
58
|
+
The Docker API is backward-compatible, which means we can specify which version of the API we want to use. Doing so is optional in order to take advantage of a specific feature.
|
59
|
+
|
60
|
+
We can specify the version to be used in 2 ways:
|
61
|
+
|
62
|
+
|
63
|
+
Use a specific version for all new instances
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
Docker::API.default_api_version="1.43"
|
67
|
+
image = Docker::API::Image.new
|
68
|
+
image.list.path
|
69
|
+
=> "/v1.43/images/json"
|
70
|
+
```
|
71
|
+
|
72
|
+
Change the version used after the instance is created
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
image = Docker::API::Image.new
|
76
|
+
image.api_version="1.43"
|
77
|
+
image.list.path
|
78
|
+
=> "/v1.43/images/json"
|
79
|
+
```
|
80
|
+
|
55
81
|
### Images
|
56
82
|
|
57
83
|
```ruby
|
data/Rakefile
CHANGED
data/dockerapi.gemspec
CHANGED
@@ -2,7 +2,7 @@ require_relative 'lib/docker/api/version'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "dockerapi"
|
5
|
-
spec.version = Docker::API::
|
5
|
+
spec.version = Docker::API::VERSION
|
6
6
|
spec.authors = ["Alysson A. Costa"]
|
7
7
|
spec.email = ["alysson.avila.costa@gmail.com"]
|
8
8
|
|
data/lib/docker/api/base.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
##
|
2
2
|
# Base class to provide general methods, helpers and implementations accross classes.
|
3
3
|
class Docker::API::Base
|
4
|
+
attr_accessor(:api_version)
|
5
|
+
|
4
6
|
[:get, :post, :head, :delete, :put].each do | method |
|
5
7
|
define_method(method) { | path, params = {} | self.request(method: method, path: path, params: params) }
|
6
8
|
end
|
@@ -24,6 +26,7 @@ class Docker::API::Base
|
|
24
26
|
def initialize connection = nil
|
25
27
|
raise StandardError.new("Expected connection to be a Docker::API::Connection class") if connection != nil && !connection.is_a?(Docker::API::Connection)
|
26
28
|
@connection = connection || Docker::API::Connection.new
|
29
|
+
@api_version = Docker::API.default_api_version
|
27
30
|
end
|
28
31
|
|
29
32
|
private
|
@@ -91,7 +94,7 @@ class Docker::API::Base
|
|
91
94
|
# @param path [String]: Base URL string.
|
92
95
|
# @param hash [Hash]: Hash object to be appended to the URL as query parameters.
|
93
96
|
def build_path path, params = {}
|
94
|
-
path = "/v#{
|
97
|
+
path = "/v#{@api_version}#{path}"
|
95
98
|
params.size > 0 ? [path, hash_to_params(params)].join("?") : path
|
96
99
|
end
|
97
100
|
|
data/lib/docker/api/version.rb
CHANGED
data/lib/dockerapi.rb
CHANGED
@@ -43,6 +43,16 @@ module Docker
|
|
43
43
|
@@print_response_to_stdout = bool
|
44
44
|
end
|
45
45
|
self.print_response_to_stdout = false
|
46
|
+
|
47
|
+
##
|
48
|
+
# This variable controls the default Docker API version.
|
49
|
+
def self.default_api_version
|
50
|
+
@@default_api_version
|
51
|
+
end
|
52
|
+
def self.default_api_version=(s)
|
53
|
+
@@default_api_version = s
|
54
|
+
end
|
55
|
+
self.default_api_version = "1.43"
|
46
56
|
|
47
57
|
end
|
48
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockerapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alysson A. Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-08-
|
11
|
+
date: 2025-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|