dockerapi 0.17.0 → 0.18.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
  SHA256:
3
- metadata.gz: 1965ae78342ecc9d450e4cc8262352405784881e31231d700dd606a15d9b58eb
4
- data.tar.gz: bea7418501d8a3c08ea73f6c6970b08afe7358c7a15e790b7d51011bb69cd721
3
+ metadata.gz: 4117775ffcd9a7ba657bbea943fd20e52de1907fcf3174850a48b8ede27a7acf
4
+ data.tar.gz: 6d7a725d087401b8d1a2806e6deee5066ed6ad3bc8f195ffcda1321b3fc2252b
5
5
  SHA512:
6
- metadata.gz: 91a6a4e8f85632f9294a07ae2e4bee24d4ff79543b1f50d240638b98d5e9bcc792193be15fa6003d97c73ec8f4b5126f0fe7294367160fce16f8eebd689b5198
7
- data.tar.gz: 8a9a1b6ee4bbe7f10c0ae1396eb51e2cb246a37f490758a0278dfe7b06612870a4c12886caf01b9a575b255decec7faf5f0f4ef9d49e2df76a3cb80e4ca06776
6
+ metadata.gz: 158707ec44efb0d7ac3123e988c670af94cd9ad054bf47dfbf6d75c2ffd516f87f85296f9732a98213913e1b827dc3de582fff7fabc25f4c359c50f704b6f1ea
7
+ data.tar.gz: 62b262e3d7fcffaaa1cec28f6dd9246619abfecfcd88b85fd90e2f18fc46806135fc17c149dc26e5a5687b4e426b5a98ad60e87b8763af4949f096280d3b229c
@@ -0,0 +1,35 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a
28
+ with:
29
+ ruby-version: 2.6
30
+ - name: Install Docker
31
+ run: curl https://get.docker.com | sh
32
+ - name: Install dependencies
33
+ run: bin/setup && sudo bin/setup
34
+ - name: Run tests
35
+ run: rake spec
data/.gitignore CHANGED
@@ -9,3 +9,7 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ resources/registry_authentication/*.key
14
+ resources/registry_authentication/*.crt
15
+ resources/registry_authentication/htpasswd
@@ -1,7 +1,15 @@
1
+ # 0.18.0
2
+
3
+ Method `Docker::API::Image#distribution` now accepts authentication parameters. Feature introduced in [PR#3](https://github.com/nu12/dockerapi/pull/3)
4
+
5
+ Contributors: @zarqman
6
+
1
7
  # 0.17.0
2
8
 
3
9
  New block execution introduced in [PR#1](https://github.com/nu12/dockerapi/pull/1).
4
10
 
11
+ Contributors: @zarqman
12
+
5
13
  # 0.16.0
6
14
 
7
15
  `Docker::API::Task#logs` method can now receive a block to replace standard output to stdout behavior.
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dockerapi (0.17.0)
5
- excon (~> 0.76.0)
4
+ dockerapi (0.18.0)
5
+ excon (~> 0.76)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -78,6 +78,7 @@ image.details("image")
78
78
 
79
79
  # Return image digest and platform information by contacting the registry.
80
80
  image.distribution("image")
81
+ image.distribution("image", {username: "janedoe", password: "password"}) # private repository
81
82
 
82
83
  # History
83
84
  image.history("image")
@@ -94,7 +95,7 @@ image.tag("current:tag", repo: "new", tag: "tag")
94
95
  # Push image
95
96
  image.push("repo:tag") # to dockerhub
96
97
  image.push("localhost:5000/repo:tag") # to local registry
97
- image.push("private/repo", {tag: "tag"}, {username: "janedoe", password: "password"} # to private repository
98
+ image.push("private/repo", {tag: "tag"}, {username: "janedoe", password: "password"}) # to private repository
98
99
 
99
100
  # Remove image
100
101
  image.remove("image")
@@ -566,6 +567,15 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
566
567
 
567
568
  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).
568
569
 
570
+ ### Release nre version
571
+
572
+ * Update CHANGELOG.
573
+ * Update README as needed.
574
+ * Update version.
575
+ * Run tests.
576
+ * Commit changes.
577
+ * Release / push version to Rubygems & Github.
578
+
569
579
  ## Contributing
570
580
 
571
581
  Bug reports and pull requests are welcome on GitHub at https://github.com/nu12/dockerapi.
data/bin/setup CHANGED
@@ -18,5 +18,13 @@ then
18
18
  else
19
19
  echo "Running bundle install"
20
20
  bundle install
21
+
22
+ echo "Creating self-signed certificate to use in tests"
23
+ openssl req -newkey rsa:2048 -nodes -keyout resources/registry_authentication/registry_auth.key -x509 -days 365 -out resources/registry_authentication/registry_auth.crt -subj "/C=CL/ST=Santiago/L=Santiago/O=dockerapi/OU=dockerapi/CN=dockerapi"
24
+
25
+ echo "Creating htpasswd file to use in tests"
26
+ docker run --rm --entrypoint htpasswd registry:2.7.0 -Bbn janedoe password > resources/registry_authentication/htpasswd
27
+ docker image rm registry:2.7.0
21
28
  echo "Run this script as root for further configurations"
22
- fi
29
+ fi
30
+
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ["lib"]
28
28
 
29
- spec.add_dependency("excon", "~> 0.76.0")
29
+ spec.add_dependency("excon", "~> 0.76")
30
30
  end
@@ -3,7 +3,7 @@
3
3
  class Docker::API::Base
4
4
 
5
5
  ##
6
- # Creates new object and sets the validation to happen automatically when method parameters include "params" or "body".
6
+ # Create new object and sets the validation to happen automatically when method parameters include "params" or "body".
7
7
  #
8
8
  # @param connection [Docker::API::Connection]: Connection to be used.
9
9
  def initialize connection = nil
@@ -15,7 +15,7 @@ class Docker::API::Base
15
15
  private
16
16
 
17
17
  ##
18
- # Outputs to stdout.
18
+ # Output to stdout.
19
19
  def default_streamer
20
20
  streamer = lambda do |chunk, remaining_bytes, total_bytes|
21
21
  p chunk.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') if Docker::API::PRINT_TO_STDOUT
@@ -24,7 +24,7 @@ class Docker::API::Base
24
24
  end
25
25
 
26
26
  ##
27
- # Writes file.
27
+ # Write file to disk.
28
28
  #
29
29
  # @param path [String]: Path to the file to be writen.
30
30
  def default_writer path
@@ -38,7 +38,7 @@ class Docker::API::Base
38
38
  end
39
39
 
40
40
  ##
41
- # Reads file.
41
+ # Read file from disk.
42
42
  #
43
43
  # @param path [String]: Path to the file to be read.
44
44
  # @param url [String]: Endpoint URL where the file is going to be sent.
@@ -52,7 +52,7 @@ class Docker::API::Base
52
52
  end
53
53
 
54
54
  ##
55
- # Encodes the authentication parameters.
55
+ # Encode authentication parameters.
56
56
  #
57
57
  # @param authentication [Hash]: Parameters to be encoded.
58
58
  def auth_encoder(authentication)
@@ -60,7 +60,7 @@ class Docker::API::Base
60
60
  end
61
61
 
62
62
  ##
63
- # Validates a Hash object comparing its keys with a given Array of permitted values. Raise an error if the validation fail.
63
+ # Validate a Hash object comparing its keys with a given Array of permitted values. Raise an error if the validation fail.
64
64
  #
65
65
  # @param error [Error]: Error to be raised of the validation fail.
66
66
  # @param permitted [Array]: List of permitted keys.
@@ -72,7 +72,7 @@ class Docker::API::Base
72
72
  end
73
73
 
74
74
  ##
75
- # Converts Ruby Hash into URL query parameters.
75
+ # Convert Ruby Hash into URL query parameters.
76
76
  #
77
77
  # In general, query parameters' format is "key=value", but if "value" is another Hash, it should change to a json syntax {key:value}.
78
78
  #
@@ -84,7 +84,7 @@ class Docker::API::Base
84
84
  end
85
85
 
86
86
  ##
87
- # Builds an URL string using the base path and a set of parameters.
87
+ # Build an URL string using the base path and a set of parameters.
88
88
  #
89
89
  # @param path [String]: Base URL string.
90
90
  # @param hash [Hash]: Hash object to be appended to the URL as query parameters.
@@ -93,7 +93,7 @@ class Docker::API::Base
93
93
  end
94
94
 
95
95
  ##
96
- # Sets the validation to happen automatically when method parameters include "params" or "body".
96
+ # Set the validation to happen automatically when method parameters include "params" or "body".
97
97
  def set_automated_validation
98
98
  (self.methods - Object.methods).each do |method|
99
99
  params_index = method(method).parameters.map{|ar| ar[1]}.index(:params)
@@ -6,7 +6,7 @@ class Docker::API::Connection
6
6
  end
7
7
 
8
8
  ##
9
- # Calls an Excon request and returns a Docker::API::Response object.
9
+ # Call an Excon request and returns a Docker::API::Response object.
10
10
  #
11
11
  # @param params [Hash]: Request parameters.
12
12
  def request params
@@ -14,7 +14,7 @@ class Docker::API::Connection
14
14
  end
15
15
 
16
16
  ##
17
- # Creates an Excon connection.
17
+ # Create an Excon connection.
18
18
  #
19
19
  # @param url [String]: URL for the connection.
20
20
  # @param params [String]: Additional parameters.
@@ -4,7 +4,7 @@
4
4
  class Docker::API::Container < Docker::API::Base
5
5
 
6
6
  ##
7
- # Returns a list of containers.
7
+ # Return a list of containers.
8
8
  #
9
9
  # Docker API: GET /containers/json
10
10
  # @see https://docs.docker.com/engine/api/v1.40/#operation/ContainerList
@@ -16,7 +16,7 @@ class Docker::API::Exec < Docker::API::Base
16
16
  end
17
17
 
18
18
  ##
19
- # Starts a previously set up exec instance.
19
+ # Start a previously set up exec instance.
20
20
  #
21
21
  # Docker API: POST /exec/{id}/start
22
22
  # @see https://docs.docker.com/engine/api/v1.40/#operation/ExecStart
@@ -21,8 +21,11 @@ class Docker::API::Image < Docker::API::Base
21
21
  # @see https://docs.docker.com/engine/api/v1.40/#tag/Distribution
22
22
  #
23
23
  # @param name [String]: The ID or name of the image.
24
- def distribution name
25
- @connection.get("/distribution/#{name}/json")
24
+ # @param authentication [Hash]: Authentication parameters.
25
+ def distribution name, authentication = {}
26
+ request = {method: :get, path: "/distribution/#{name}/json"}
27
+ request[:headers] = {"X-Registry-Auth" => auth_encoder(authentication)} if authentication.any?
28
+ @connection.request(request)
26
29
  end
27
30
 
28
31
  ##
@@ -37,7 +40,7 @@ class Docker::API::Image < Docker::API::Base
37
40
  end
38
41
 
39
42
  ##
40
- # Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
43
+ # Return a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
41
44
  #
42
45
  # Docker API: GET /images/json
43
46
  # @see https://docs.docker.com/engine/api/v1.40/#operation/ImageList
@@ -130,7 +133,7 @@ class Docker::API::Image < Docker::API::Base
130
133
  # @param params [Hash]: Parameters that are appended to the URL.
131
134
  # @param authentication [Hash]: Authentication parameters.
132
135
  def push name, params = {}, authentication = {}
133
- raise Docker::API::Error.new("Provide authentication parameters to push an image") unless authentication.keys.size > 0
136
+ raise Docker::API::Error.new("Provide authentication parameters to push an image") unless authentication.any?
134
137
  @connection.request(method: :post, path: build_path("/images/#{name}/push", params), headers: { "X-Registry-Auth" => auth_encoder(authentication) } )
135
138
  end
136
139
 
@@ -164,7 +167,7 @@ class Docker::API::Image < Docker::API::Base
164
167
  params[:fromSrc] = "-"
165
168
  default_reader(path, build_path("/images/create", params))
166
169
  else
167
- request[:headers] = { "X-Registry-Auth" => auth_encoder(authentication) } if authentication.keys.size > 0
170
+ request[:headers] = { "X-Registry-Auth" => auth_encoder(authentication) } if authentication.any?
168
171
  @connection.request(request)
169
172
  end
170
173
  end
@@ -183,7 +186,7 @@ class Docker::API::Image < Docker::API::Base
183
186
  raise Docker::API::Error.new("Expected path or params[:remote]") unless path || params[:remote]
184
187
 
185
188
  headers = {"Content-type": "application/x-tar"}
186
- headers.merge!({"X-Registry-Config": auth_encoder(authentication) }) if authentication.keys.size > 0
189
+ headers.merge!({"X-Registry-Config": auth_encoder(authentication) }) if authentication.any?
187
190
 
188
191
  if path == nil and params.has_key? :remote
189
192
  response = @connection.request(method: :post, path: build_path("/build", params), headers: headers, response_block: block_given? ? block : default_streamer)
@@ -14,7 +14,7 @@ class Docker::API::Response < Excon::Response
14
14
  end
15
15
 
16
16
  ##
17
- # Returns true if Response status is in 200..204 range.
17
+ # Return true if Response status is in 200..204 range.
18
18
  def success?
19
19
  (200..204).include? @status
20
20
  end
@@ -22,7 +22,7 @@ class Docker::API::Response < Excon::Response
22
22
  private
23
23
 
24
24
  ##
25
- # Creates a json from Response data attribute.
25
+ # Create a json from Response data attribute.
26
26
  #
27
27
  # @params data [String]: String to be converted in json.
28
28
  def parse_json data
@@ -45,7 +45,7 @@ class Docker::API::System < Docker::API::Base
45
45
  end
46
46
 
47
47
  ##
48
- # Returns the version of Docker that is running and various information about the system that Docker is running on.
48
+ # Return the version of Docker that is running and various information about the system that Docker is running on.
49
49
  #
50
50
  # Docker API: GET /version
51
51
  # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemVersion
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  module API
3
- GEM_VERSION = "0.17.0"
3
+ GEM_VERSION = "0.18.0"
4
4
 
5
5
  API_VERSION = "1.40"
6
6
 
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.17.0
4
+ version: 0.18.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-10-29 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.76.0
19
+ version: '0.76'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.76.0
26
+ version: '0.76'
27
27
  description: Interact with Docker API directly from Ruby code. Comprehensive implementation
28
28
  (all available endpoints), no local Docker installation required, easily manipulated
29
29
  http responses.
@@ -33,9 +33,9 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
+ - ".github/workflows/ruby.yml"
36
37
  - ".gitignore"
37
38
  - ".rspec"
38
- - ".travis.yml"
39
39
  - CHANGELOG.md
40
40
  - Gemfile
41
41
  - Gemfile.lock
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.1.4
90
+ rubygems_version: 3.1.2
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Interact with Docker API from Ruby code.
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.1
6
- before_install: gem install bundler -v 2.1.4