dockerapi 0.20.1 → 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: 71931122b06d9ba3d0234d6f053286e6397b420e76c8cc8d20b5fe0a37954a9c
4
- data.tar.gz: b81f61be9510e0017c27dbadda88134da47bf92046e6c4b187f7be0d3eab5bb4
3
+ metadata.gz: f437d91a99a54403c5f945d2f9814d21cdf4ddde861a9aa6a0cb5fc8733407db
4
+ data.tar.gz: d80832f6576d633db58dc546496604fa30b94e4f1dd3020cfabcd61df538ec99
5
5
  SHA512:
6
- metadata.gz: 5a2b71b4b8ceffe3110d174a6104176c919fe1f2fca7bb1677bbc5b2e17300616cbcaf3a2ddeac984ca28852e88a8b17f9ff3a5b774b4c884e6c8059c4e1da08
7
- data.tar.gz: 02af72c0856a6b7eaaae49e90e187f7aa99532accfb862b8d37b0ea65da3e09076509bd87ad9efc22f109853d44e557ecac0d6cdbc543dea0d4606ac0bce77a1
6
+ metadata.gz: 2620eb13fad97f0f6529db6f3d6501351790e1d6ca90200c24ed7aef34db1179d3e6c8f6cb4d780dc046c0bc6a45c0ed23f2dff75f336ddfd6c17c33e699ee2a
7
+ data.tar.gz: 8b757f7abb03f9fe449caadc09407beac250a9c605ed493e6aabdae2be0471666003ffb9f58fb67fba42fcc201b549b803748a0089865086abd7c3262f3a1898
@@ -17,3 +17,5 @@ jobs:
17
17
  run: bundle install
18
18
  - name: Run unit tests
19
19
  run: rspec
20
+ - name: Run E2E tests
21
+ run: rspec --tag e2e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dockerapi (0.20.1)
4
+ dockerapi (0.21.0)
5
5
  base64
6
6
  excon (>= 0.97, < 2)
7
7
 
data/README.md CHANGED
@@ -552,12 +552,6 @@ response.success?
552
552
  => true
553
553
  ```
554
554
 
555
- ### Error handling
556
-
557
- `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.
558
-
559
- To completely skip the validation process, add `:skip_validation => true` in the hash to be validated.
560
-
561
555
  ### Blocks
562
556
 
563
557
  Some methods can receive a block to alter the default execution:
@@ -586,7 +580,7 @@ The default blocks can be found in `Docker::API::Base`.
586
580
 
587
581
  ## Development
588
582
 
589
- Run `rake spec` to run the tests.
583
+ Run `rspec` to run the unit tests. Run `rspec --tag e2e` to run End-to-End tests (requires Docker locally).
590
584
 
591
585
  Run `bin/console` for an interactive prompt that will allow you to experiment.
592
586
 
@@ -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
@@ -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
 
@@ -93,19 +80,4 @@ class Docker::API::Base
93
80
  params.size > 0 ? [path, hash_to_params(params)].join("?") : path
94
81
  end
95
82
 
96
- ##
97
- # Set the validation to happen automatically when method parameters include "params" or "body".
98
- def set_automated_validation
99
- (self.methods - Object.methods).each do |method|
100
- params_index = method(method).parameters.map{|ar| ar[1]}.index(:params)
101
- body_index = method(method).parameters.map{|ar| ar[1]}.index(:body)
102
-
103
- define_singleton_method(method) do |*args, &block|
104
- validate Docker::API::InvalidParameter, Docker::API::VALID_PARAMS["#{self.class.name}"]["#{method}"], (args[params_index] || {}) if params_index
105
- validate Docker::API::InvalidRequestBody, Docker::API::VALID_BODY["#{self.class.name}"]["#{method}"], (args[body_index] || {}) if body_index
106
- super(*args,&block)
107
- end
108
- end
109
- end
110
-
111
83
  end
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  module API
3
- GEM_VERSION = "0.20.1"
3
+ GEM_VERSION = "0.21.0"
4
4
 
5
5
  API_VERSION = "1.43"
6
6
 
data/lib/dockerapi.rb CHANGED
@@ -4,7 +4,6 @@ require "base64"
4
4
  require "fileutils"
5
5
 
6
6
  require "docker/api/version"
7
- require "docker/api/error"
8
7
  require "docker/api/connection"
9
8
  require "docker/api/response"
10
9
  require "docker/api/base"
@@ -44,144 +43,6 @@ module Docker
44
43
  @@print_response_to_stdout = bool
45
44
  end
46
45
  self.print_response_to_stdout = false
47
-
48
- ##
49
- # Valid values for parameter validations.
50
- VALID_PARAMS = {
51
- "Docker::API::Image" => {
52
- "build" => [:dockerfile, :t, :extrahosts, :remote, :q, :nocache, :cachefrom, :pull, :rm, :forcerm, :memory, :memswap, :cpushares, :cpusetcpus, :cpuperiod, :cpuquota, :buildargs, :shmsize, :squash, :labels, :networkmode, :platform, :target, :outputs],
53
- "prune" => [:filters],
54
- "list" => [:all, :filters, "shared-size", :digests],
55
- "search" => [:term, :limit, :filters],
56
- "tag" => [:repo, :tag],
57
- "remove" => [:force, :noprune],
58
- "import" => [:quiet],
59
- "push" => [:tag],
60
- "commit" => [:container, :repo, :tag, :comment, :author, :pause, :changes],
61
- "create" => [:fromImage, :fromSrc, :repo, :tag, :message, :changes, :platform],
62
- "delete_cache" => [:all, "keep-storage", :filters]
63
- },
64
- "Docker::API::Container" => {
65
- "list" => [:all, :limit, :size, :filters],
66
- "details" => [:size],
67
- "top" => [:ps_args],
68
- "start" => [:detachKeys],
69
- "stop" => [:signal, :t],
70
- "restart" => [:signal, :t],
71
- "kill" => [:signal],
72
- "wait" => [:condition],
73
- "rename" => [:name],
74
- "resize" => [:w, :h],
75
- "prune" => [:filters],
76
- "remove" => [:v, :force, :link],
77
- "logs" => [:follow, :stdout, :stderr, :since, :until, :timestamps, :tail],
78
- "attach" => [:detachKeys, :logs, :stream, :stdin, :stdout, :stderr],
79
- "stats" => [:stream, "one-shot"],
80
- "get_archive" => [:path],
81
- "put_archive" => [:path, :noOverwriteDirNonDir, :copyUIDGID],
82
- "create" => [:name, :platform]
83
- },
84
- "Docker::API::Volume" => {
85
- "list" => [:filters],
86
- "remove" => [:force],
87
- "prune" => [:filters]
88
- },
89
- "Docker::API::Network" => {
90
- "list" => [:filters],
91
- "details" => [:verbose, :scope],
92
- "prune" => [:filters]
93
- },
94
- "Docker::API::System" => {
95
- "events" => [:since, :until, :filters],
96
- "df" => [:type]
97
- },
98
- "Docker::API::Exec" => {
99
- "resize" => [:w, :h]
100
- },
101
- "Docker::API::Swarm" => {
102
- "leave" => [:force],
103
- "update" => [:version, :rotateWorkerToken, :rotateManagerToken, :rotateManagerUnlockKey]
104
- },
105
- "Docker::API::Node" => {
106
- "list" => [:filters],
107
- "update" => [:version],
108
- "delete" => [:force]
109
- },
110
- "Docker::API::Service" => {
111
- "list" => [:filters, :status],
112
- "update" => [:version, :registryAuthFrom, :rollback],
113
- "details" => [:insertDefaults],
114
- "logs" => [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail]
115
- },
116
- "Docker::API::Secret" => {
117
- "list" => [:filters],
118
- "update" => [:version]
119
- },
120
- "Docker::API::Task" => {
121
- "list" => [:filters],
122
- "logs" => [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail]
123
- },
124
- "Docker::API::Plugin" => {
125
- "list" => [:filters],
126
- "privileges" => [:remote],
127
- "install" => [:remote, :name],
128
- "remove" => [:force],
129
- "enable" => [:timeout],
130
- "upgrade" => [:remote]
131
- },
132
- "Docker::API::Config" => {
133
- "list" => [:filters],
134
- "update" => [:version]
135
- }
136
- }
137
-
138
- ##
139
- # Valid values for request body validations.
140
- VALID_BODY = {
141
- "Docker::API::Image" => {
142
- "commit" => [:Hostname, :Domainname, :User, :AttachStdin, :AttachStdout, :AttachStderr, :ExposedPorts, :Tty, :OpenStdin, :StdinOnce, :Env, :Cmd, :HealthCheck, :ArgsEscaped, :Image, :Volumes, :WorkingDir, :Entrypoint, :NetworkDisabled, :MacAddress, :OnBuild, :Labels, :StopSignal, :StopTimeout, :Shell]
143
- },
144
- "Docker::API::Container" => {
145
- "create" => [:Hostname,:Domainname,:User,:AttachStdin,:AttachStdout,:AttachStderr,:ExposedPorts,:Tty,:OpenStdin,:StdinOnce,:Env,:Cmd,:HealthCheck,:ArgsEscaped,:Image,:Volumes,:WorkingDir,:Entrypoint,:NetworkDisabled,:MacAddress,:OnBuild,:Labels,:StopSignal,:StopTimeout,:Shell,:HostConfig,:NetworkingConfig],
146
- "update" => [:CpuShares, :Memory, :CgroupParent, :BlkioWeight, :BlkioWeightDevice, :BlkioDeviceReadBps, :BlkioDeviceWriteBps, :BlkioDeviceReadIOps, :BlkioDeviceWriteIOps, :CpuPeriod, :CpuQuota, :CpuRealtimePeriod, :CpuRealtimeRuntime, :CpusetCpus, :CpusetMems, :Devices, :DeviceCgroupRules, :DeviceRequest, :Memory, :KernelMemoryTCP, :MemoryReservation, :MemorySwap, :MemorySwappiness, :NanoCPUs, :OomKillDisable, :Init, :PidsLimit, :ULimits, :CpuCount, :CpuPercent, :IOMaximumIOps, :IOMaximumBandwidth, :RestartPolicy]
147
- },
148
- "Docker::API::Volume" => {
149
- "create" => [:Name, :Driver, :DriverOpts, :Labels, :ClusterVolumeSpec]
150
- },
151
- "Docker::API::Network" => {
152
- "create" => [:Name, :CheckDuplicate, :Driver, :Internal, :Attachable, :Ingress, :IPAM, :EnableIPv6, :Options, :Labels],
153
- "connect" => [:Container, :EndpointConfig],
154
- "disconnect" => [:Container, :Force]
155
- },
156
- "Docker::API::System" => {
157
- "auth" => [:username, :password, :email, :serveraddress, :identitytoken]
158
- },
159
- "Docker::API::Exec" => {
160
- "create" => [:AttachStdin, :AttachStdout, :AttachStderr, :ConsoleSize, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir],
161
- "start" => [:Detach, :Tty, :ConsoleSize]
162
- },
163
- "Docker::API::Swarm" => {
164
- "init" => [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :DataPathPort, :DefaultAddrPool, :ForceNewCluster, :SubnetSize, :Spec],
165
- "update" => [:Name, :Labels, :Orchestration, :Raft, :Dispatcher, :CAConfig, :EncryptionConfig, :TaskDefaults],
166
- "unlock" => [:UnlockKey],
167
- "join" => [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :RemoteAddrs, :JoinToken]
168
- },
169
- "Docker::API::Node" => {
170
- "update" => [:Name, :Labels, :Role, :Availability]
171
- },
172
- "Docker::API::Service" => {
173
- "create" => [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec],
174
- "update" => [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec]
175
- },
176
- "Docker::API::Secret" => {
177
- "create" => [:Name, :Labels, :Data, :Driver, :Templating],
178
- "update" => [:Name, :Labels, :Data, :Driver, :Templating]
179
- },
180
- "Docker::API::Config" => {
181
- "create" => [:Name, :Labels, :Data, :Templating],
182
- "update" => [:Name, :Labels, :Data, :Templating]
183
- }
184
- }
185
46
 
186
47
  end
187
48
  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.20.1
4
+ version: 0.21.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-01 00:00:00.000000000 Z
11
+ date: 2025-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -68,7 +68,6 @@ files:
68
68
  - lib/docker/api/config.rb
69
69
  - lib/docker/api/connection.rb
70
70
  - lib/docker/api/container.rb
71
- - lib/docker/api/error.rb
72
71
  - lib/docker/api/exec.rb
73
72
  - lib/docker/api/image.rb
74
73
  - lib/docker/api/network.rb
@@ -1,33 +0,0 @@
1
- module Docker
2
- module API
3
-
4
- ##
5
- # This class represents a validation error.
6
- class ValidationError < StandardError
7
-
8
- ##
9
- # @params permitted [Array]: permitted values.
10
- # @params unpermitted [Array]: unpermitted values.
11
- def initialize permitted, unpermitted
12
- super("Unpermitted options found: #{unpermitted.to_s}. Permitted are #{permitted.to_s}")
13
- end
14
- end
15
-
16
- ##
17
- # This class represents a parameter validation error.
18
- class InvalidParameter < Docker::API::ValidationError; end
19
-
20
- ##
21
- # This class represents a request body validation error.
22
- class InvalidRequestBody < Docker::API::ValidationError; end
23
-
24
- ##
25
- # This class represents a generic error.
26
- class Error < StandardError
27
- def initialize msg = "Error without specific message"
28
- super(msg)
29
- end
30
- end
31
-
32
- end
33
- end