dockerapi 0.11.0 → 0.12.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/CHANGELOG.md +15 -0
- data/Gemfile.lock +1 -1
- data/README.md +43 -2
- data/lib/docker/api/plugin.rb +166 -0
- data/lib/docker/api/version.rb +1 -1
- data/lib/dockerapi.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a32e488d06a0afd653bb04ab0ad5131fa8e898973128d7a6661f3d3fa4eae53d
|
4
|
+
data.tar.gz: 641ffcc096f798fbfff057fb1eecc7ce97ad9191c2acf49f5e97c90bf5ceddc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cda72170483e133b467a399d77fbcc7668793726b8f67beb4235c5eaf74e2d91977c9544f93ee7d3f3c4b681004d9415f939d2d521aa70151d3a580fc15fc86
|
7
|
+
data.tar.gz: d45997041c9d706d2c2d0e2c5e3f5ccaedad51d71cb27ba8538898565e6259e30d7ff11ffa60a5dee9ffca3611ed51ddc96ca68af2a5aff490715b4645297c0d
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -391,9 +391,50 @@ config.update("config-name", {version: version}, spec.merge!({ Data: "VEhJUyBJUy
|
|
391
391
|
config.delete("config-name")
|
392
392
|
```
|
393
393
|
|
394
|
+
### Plugin
|
395
|
+
```ruby
|
396
|
+
# Connect to local plugin endpoints
|
397
|
+
plugin = Docker::API::Plugin.new
|
398
|
+
|
399
|
+
# List plugins
|
400
|
+
plugin.list
|
401
|
+
|
402
|
+
# List plugin's privileges
|
403
|
+
plugin.privileges(remote: "plugin-name")
|
404
|
+
|
405
|
+
# Install plugin (using defined privileges)
|
406
|
+
privileges = plugin.privileges(remote: "plugin-name")
|
407
|
+
plugin.install({remote: "plugin-name"}, privileges)
|
408
|
+
|
409
|
+
# Upgrade plugin (using defined privileges)
|
410
|
+
privileges = plugin.privileges(remote: "plugin-name2")
|
411
|
+
plugin.upgrade("plugin-name", {remote: "plugin-name2"}, privileges)
|
412
|
+
|
413
|
+
# Enable plugin
|
414
|
+
plugin.enable("plugin-name", timeout: 0)
|
415
|
+
|
416
|
+
# Disable plugin
|
417
|
+
plugin.disable("plugin-name")
|
418
|
+
|
419
|
+
# Configure plugin
|
420
|
+
plugin.configure("plugin-name", ["DEBUG=1"])
|
421
|
+
|
422
|
+
# Inspect plugin
|
423
|
+
plugin.details("plugin-name")
|
424
|
+
|
425
|
+
# Remove plugin
|
426
|
+
plugin.remove("plugin-name")
|
427
|
+
|
428
|
+
# Create plugin (tar file must contain rootfs folder and config.json file)
|
429
|
+
plugin.create("name", "/path/to/file.tar")
|
430
|
+
|
431
|
+
# Push plugin
|
432
|
+
plugin.push("name")
|
433
|
+
```
|
434
|
+
|
394
435
|
### Connection
|
395
436
|
|
396
|
-
By default Docker::API::Connection will connect to local Docker socket at `/var/run/docker.sock`. See examples below to use a different path or connect to a remote address.
|
437
|
+
By default `Docker::API::Connection` will connect to local Docker socket at `/var/run/docker.sock`. See examples below to use a different path or connect to a remote address.
|
397
438
|
|
398
439
|
```ruby
|
399
440
|
# Setting different connections
|
@@ -478,7 +519,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
478
519
|
| Secret | Ok | Ok | 9/4 |
|
479
520
|
| Config | Ok | Ok | 9/4 |
|
480
521
|
| Distribution | Ok | Ok | 9/4 |
|
481
|
-
| Plugin |
|
522
|
+
| Plugin | Ok | 7/24 | 9/4 |
|
482
523
|
|
483
524
|
## Contributing
|
484
525
|
|
@@ -0,0 +1,166 @@
|
|
1
|
+
# This class represents the Docker API endpoints regarding plugins.
|
2
|
+
#
|
3
|
+
# @see https://docs.docker.com/engine/api/v1.40/#tag/Plugin
|
4
|
+
class Docker::API::Plugin < Docker::API::Base
|
5
|
+
|
6
|
+
# List plugins
|
7
|
+
#
|
8
|
+
# Docker API: GET /plugins
|
9
|
+
#
|
10
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginList
|
11
|
+
#
|
12
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
13
|
+
def list params = {}
|
14
|
+
validate Docker::API::InvalidParameter, [:filters], params
|
15
|
+
@connection.get(build_path("/plugins", params))
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get plugin privileges
|
19
|
+
#
|
20
|
+
# Docker API: GET /plugins/privileges
|
21
|
+
#
|
22
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/GetPluginPrivileges
|
23
|
+
#
|
24
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
25
|
+
def privileges params = {}
|
26
|
+
validate Docker::API::InvalidParameter, [:remote], params
|
27
|
+
@connection.get(build_path("/plugins/privileges", params))
|
28
|
+
end
|
29
|
+
|
30
|
+
# Install a plugin
|
31
|
+
#
|
32
|
+
# Pulls and installs a plugin. After the plugin is installed, it can be enabled using the POST /plugins/{name}/enable endpoint.
|
33
|
+
#
|
34
|
+
# Docker API: POST /plugins/pull
|
35
|
+
#
|
36
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginPull
|
37
|
+
#
|
38
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
39
|
+
#
|
40
|
+
# @param privileges [Array]: Plugin privileges to be sent as json in request body.
|
41
|
+
#
|
42
|
+
# @param authentication [Hash]: Authentication parameters.
|
43
|
+
def install params = {}, privileges = [], authentication = {}
|
44
|
+
validate Docker::API::InvalidParameter, [:remote, :name], params
|
45
|
+
headers = {"Content-Type": "application/json"}
|
46
|
+
headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
|
47
|
+
@connection.request(method: :post, path: build_path("/plugins/pull", params), headers: headers, body: privileges.to_json )
|
48
|
+
end
|
49
|
+
|
50
|
+
# Inspect a plugin
|
51
|
+
#
|
52
|
+
# Docker API: GET /plugins/{name}/json
|
53
|
+
#
|
54
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginInspect
|
55
|
+
#
|
56
|
+
# @param name [String]: The ID or name of the plugin.
|
57
|
+
def details name
|
58
|
+
@connection.get("/plugins/#{name}/json")
|
59
|
+
end
|
60
|
+
|
61
|
+
# Remove a plugin
|
62
|
+
#
|
63
|
+
# Docker API: DELETE /plugins/{name}
|
64
|
+
#
|
65
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginDelete
|
66
|
+
#
|
67
|
+
# @param name [String]: The ID or name of the plugin.
|
68
|
+
#
|
69
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
70
|
+
def remove name, params = {}
|
71
|
+
validate Docker::API::InvalidParameter, [:force], params
|
72
|
+
@connection.delete(build_path("/plugins/#{name}",params))
|
73
|
+
end
|
74
|
+
|
75
|
+
# Enable a plugin
|
76
|
+
#
|
77
|
+
# Docker API: POST /plugins/{name}/enable
|
78
|
+
#
|
79
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginEnable
|
80
|
+
#
|
81
|
+
# @param name [String]: The ID or name of the plugin.
|
82
|
+
#
|
83
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
84
|
+
def enable name, params = {}
|
85
|
+
validate Docker::API::InvalidParameter, [:timeout], params
|
86
|
+
@connection.post(build_path("/plugins/#{name}/enable", params))
|
87
|
+
end
|
88
|
+
|
89
|
+
# Disable a plugin
|
90
|
+
#
|
91
|
+
# Docker API: POST /plugins/{name}/disable
|
92
|
+
#
|
93
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginDisable
|
94
|
+
#
|
95
|
+
# @param name [String]: The ID or name of the plugin.
|
96
|
+
def disable name
|
97
|
+
@connection.post("/plugins/#{name}/disable")
|
98
|
+
end
|
99
|
+
|
100
|
+
# Upgrade a plugin
|
101
|
+
#
|
102
|
+
# Docker API: POST /plugins/{name}/upgrade
|
103
|
+
#
|
104
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginUpgrade
|
105
|
+
#
|
106
|
+
# @param name [String]: The ID or name of the plugin.
|
107
|
+
#
|
108
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
109
|
+
#
|
110
|
+
# @param privileges [Array]: Plugin privileges to be sent as json in request body.
|
111
|
+
#
|
112
|
+
# @param authentication [Hash]: Authentication parameters.
|
113
|
+
def upgrade name, params = {}, privileges = [], authentication = {}
|
114
|
+
validate Docker::API::InvalidParameter, [:remote], params
|
115
|
+
headers = {"Content-Type": "application/json"}
|
116
|
+
headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
|
117
|
+
@connection.request(method: :post, path: build_path("/plugins/#{name}/upgrade", params), headers: headers, body: privileges.to_json )
|
118
|
+
end
|
119
|
+
|
120
|
+
# Create a plugin
|
121
|
+
#
|
122
|
+
# Docker API: POST /plugins/create
|
123
|
+
#
|
124
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginCreate
|
125
|
+
#
|
126
|
+
# @param name [String]: The ID or name of the plugin.
|
127
|
+
#
|
128
|
+
# @param path [String]: Path to tar file that contains rootfs folder and config.json file.
|
129
|
+
def create name, path
|
130
|
+
file = File.open( File.expand_path( path ) , "r")
|
131
|
+
response = @connection.request(method: :post, path: "/plugins/create?name=#{name}", body: file.read.to_s )
|
132
|
+
file.close
|
133
|
+
response
|
134
|
+
end
|
135
|
+
|
136
|
+
# Push a plugin to the registry.
|
137
|
+
#
|
138
|
+
# Docker API: POST /plugins/{name}/push
|
139
|
+
#
|
140
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginPush
|
141
|
+
#
|
142
|
+
# @param name [String]: The ID or name of the plugin.
|
143
|
+
#
|
144
|
+
# @param authentication [Hash]: Authentication parameters.
|
145
|
+
def push name, authentication = {}
|
146
|
+
if authentication.keys.size > 0
|
147
|
+
@connection.request(method: :post, path: "/plugins/#{name}/push", headers: {"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)})
|
148
|
+
else
|
149
|
+
@connection.post("/plugins/#{name}/push")
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Configure a plugin
|
154
|
+
#
|
155
|
+
# Docker API: POST /plugins/{name}/set
|
156
|
+
#
|
157
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginSet
|
158
|
+
#
|
159
|
+
# @param name [String]: The ID or name of the plugin.
|
160
|
+
#
|
161
|
+
# @param config [Array]: Plugin configuration to be sent as json in request body.
|
162
|
+
def configure name, config
|
163
|
+
@connection.request(method: :post, path: "/plugins/#{name}/set", headers: {"Content-Type": "application/json"}, body:config.to_json)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
data/lib/docker/api/version.rb
CHANGED
data/lib/dockerapi.rb
CHANGED
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: 0.12.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: 2020-07-
|
11
|
+
date: 2020-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/docker/api/image.rb
|
53
53
|
- lib/docker/api/network.rb
|
54
54
|
- lib/docker/api/node.rb
|
55
|
+
- lib/docker/api/plugin.rb
|
55
56
|
- lib/docker/api/response.rb
|
56
57
|
- lib/docker/api/secret.rb
|
57
58
|
- lib/docker/api/service.rb
|