From 2839bec03a771d1cef398000382372065346f642 Mon Sep 17 00:00:00 2001 From: thomas morgan Date: Thu, 31 Oct 2024 14:59:38 -0600 Subject: [PATCH 1/5] allow excon 1.x and require base64 for modern rubies --- Gemfile.lock | 6 ++++-- dockerapi.gemspec | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index eecaf16..79891e8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,13 +2,15 @@ PATH remote: . specs: dockerapi (0.20.0) - excon (~> 0.79) + base64 + excon (>= 0.97, < 2) GEM remote: https://rubygems.org/ specs: + base64 (0.2.0) diff-lcs (1.5.1) - excon (0.112.0) + excon (1.1.1) rake (12.3.3) rspec (3.13.0) rspec-core (~> 3.13.0) diff --git a/dockerapi.gemspec b/dockerapi.gemspec index bad65f8..27e3f69 100644 --- a/dockerapi.gemspec +++ b/dockerapi.gemspec @@ -26,5 +26,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency("excon", "~> 0.79") + spec.add_dependency("base64") + spec.add_dependency("excon", ">= 0.97", "< 2") end From 6b491a42c95461cf07efeac808751c3b1864c30b Mon Sep 17 00:00:00 2001 From: thomas morgan Date: Tue, 5 Nov 2024 11:57:02 -0700 Subject: [PATCH 2/5] update old github links --- dockerapi.gemspec | 2 +- spec/endpoints/image_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dockerapi.gemspec b/dockerapi.gemspec index 27e3f69..08cc64e 100644 --- a/dockerapi.gemspec +++ b/dockerapi.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |spec| spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = "https://github.com/nu12/dockerapi.git" - spec.metadata["changelog_uri"] = "https://github.com/nu12/dockerapi/blob/master/CHANGELOG.md" + spec.metadata["changelog_uri"] = "https://github.com/nu12/dockerapi/blob/main/CHANGELOG.md" spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/dockerapi" # Specify which files should be added to the gem when it is released. diff --git a/spec/endpoints/image_spec.rb b/spec/endpoints/image_spec.rb index d7fab87..fded3d2 100644 --- a/spec/endpoints/image_spec.rb +++ b/spec/endpoints/image_spec.rb @@ -17,7 +17,7 @@ it { expect(subject.create(fromSrc: path, repo: image, message: "Imported with dockerapi").status).to eq(200) } end context "from remote tar file" do - let(:url) { "https://github.com/nu12/dockerapi/blob/master/resources/busybox.tar?raw=true" } + let(:url) { "https://github.com/nu12/dockerapi/raw/refs/heads/main/resources/busybox.tar" } it { expect(subject.create(fromSrc: url).status).to eq(200) } it { expect(subject.create(fromSrc: url, repo: image, message: "Imported with dockerapi").status).to eq(200) } it { expect(subject.create(fromSrc: "http://404").status).to eq(500) } @@ -175,7 +175,7 @@ it { expect(subject.build("resources/build.tar.xz", memory: 4000000, rm: true, forcerm:true).status).to eq(200) } it { expect(subject.build("resources/build.tar.xz", memory: 4000000, rm: true, forcerm:true, pull:true).status).to eq(200) } it { expect(subject.build(nil, remote: "https://github.com/nu12/dockerapi/raw/refs/heads/main/resources/build.tar.xz").status).to eq(200) } - it { expect(subject.build(nil, remote: "https://raw.githubusercontent.com/nu12/dockerapi/master/resources/Dockerfile").status).to eq(200) } + it { expect(subject.build(nil, remote: "https://raw.githubusercontent.com/nu12/dockerapi/main/resources/Dockerfile").status).to eq(200) } it { expect{subject.build("resources/build.tar.xz", invalid: "invalid")}.to raise_error(Docker::API::InvalidParameter) } it { expect{subject.build(nil, remote: "https://github.com/nu12/dockerapi/raw/refs/heads/main/resources/build.tar.xz", invalid: "invalid")}.to raise_error(Docker::API::InvalidParameter) } it { expect{subject.build(nil, invalid: "invalid", skip_validation: true)}.to raise_error(Docker::API::Error) } From 75889f6e5454e8603d2f1335d650815df3ffeb6c Mon Sep 17 00:00:00 2001 From: thomas morgan Date: Tue, 5 Nov 2024 12:04:56 -0700 Subject: [PATCH 3/5] silence ruby warnings --- lib/docker/api/base.rb | 2 +- lib/docker/api/connection.rb | 2 +- lib/dockerapi.rb | 15 +++++++++++++-- spec/endpoints/image_spec.rb | 4 ++-- spec/spec_helper.rb | 4 ++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/docker/api/base.rb b/lib/docker/api/base.rb index 49f0c9b..57aff2c 100644 --- a/lib/docker/api/base.rb +++ b/lib/docker/api/base.rb @@ -18,7 +18,7 @@ def initialize connection = nil # Output to stdout. def default_streamer streamer = lambda do |chunk, remaining_bytes, total_bytes| - p chunk.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') if Docker::API::PRINT_TO_STDOUT + p chunk.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') if Docker::API.print_to_stdout end streamer end diff --git a/lib/docker/api/connection.rb b/lib/docker/api/connection.rb index 81bc5f1..8a91c6e 100644 --- a/lib/docker/api/connection.rb +++ b/lib/docker/api/connection.rb @@ -11,7 +11,7 @@ class Docker::API::Connection # @param params [Hash]: Request parameters. def request params response = Docker::API::Response.new(@connection.request(params).data) - p response if Docker::API::PRINT_RESPONSE_TO_STDOUT + p response if Docker::API.print_response_to_stdout response end diff --git a/lib/dockerapi.rb b/lib/dockerapi.rb index 769151e..838552a 100644 --- a/lib/dockerapi.rb +++ b/lib/dockerapi.rb @@ -27,11 +27,22 @@ module API ## # This variable controls output verbosity. - PRINT_TO_STDOUT = true + def self.print_to_stdout + @@print_to_stdout + end + def self.print_to_stdout=(bool) + @@print_to_stdout = bool + end + self.print_to_stdout = true ## # This variable controls output verbosity. - PRINT_RESPONSE_TO_STDOUT = false + def self.print_response_to_stdout + @@print_response_to_stdout + end + def self.print_response_to_stdout=(bool) + @@print_response_to_stdout = bool + end ## # Valid values for parameter validations. diff --git a/spec/endpoints/image_spec.rb b/spec/endpoints/image_spec.rb index fded3d2..fedb868 100644 --- a/spec/endpoints/image_spec.rb +++ b/spec/endpoints/image_spec.rb @@ -223,7 +223,7 @@ described_class.new.tag(original, repo: local) - Docker::API::PRINT_RESPONSE_TO_STDOUT = true + Docker::API.print_response_to_stdout = true end it { expect(Docker::API::Container.new.list.json.size).to be > 0 } @@ -248,7 +248,7 @@ end after(:all) do - Docker::API::PRINT_RESPONSE_TO_STDOUT = false + Docker::API.print_response_to_stdout = false container = Docker::API::Container.new container.stop("registry") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6049973..d427246 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,9 @@ require "bundler/setup" require "dockerapi" -Docker::API::PRINT_TO_STDOUT = false +Docker::API.print_to_stdout = false -Docker::API::PRINT_RESPONSE_TO_STDOUT = false +Docker::API.print_response_to_stdout = false RSpec.configure do |config| # Enable flags like --only-failures and --next-failure From 29b1925df1b2c1c13d0532f489938a249c5b80e1 Mon Sep 17 00:00:00 2001 From: thomas morgan Date: Tue, 5 Nov 2024 12:09:32 -0700 Subject: [PATCH 4/5] update minumum ruby to 3.0 --- .github/workflows/cd.yml | 2 +- Gemfile | 2 +- Gemfile.lock | 4 ++-- dockerapi.gemspec | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 5a84f3b..5b5c85b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -24,7 +24,7 @@ jobs: printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials - name: Install dependencies run: | - gem update --system 3.2.3 + gem update --system 3.5.11 bundle install - name: Release run: | diff --git a/Gemfile b/Gemfile index dbc2356..8253e48 100644 --- a/Gemfile +++ b/Gemfile @@ -3,5 +3,5 @@ source "https://rubygems.org" # Specify your gem's dependencies in dockerapi.gemspec gemspec -gem "rake", "~> 12.0" +gem "rake", "~> 13.0" gem "rspec", "~> 3.0" diff --git a/Gemfile.lock b/Gemfile.lock index 79891e8..b2f4551 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GEM base64 (0.2.0) diff-lcs (1.5.1) excon (1.1.1) - rake (12.3.3) + rake (13.2.1) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -32,7 +32,7 @@ PLATFORMS DEPENDENCIES dockerapi! - rake (~> 12.0) + rake (~> 13.0) rspec (~> 3.0) BUNDLED WITH diff --git a/dockerapi.gemspec b/dockerapi.gemspec index 08cc64e..e8b153d 100644 --- a/dockerapi.gemspec +++ b/dockerapi.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |spec| spec.description = "Interact with Docker API directly from Ruby code. Comprehensive implementation (all available endpoints), no local Docker installation required, easily manipulated http responses." spec.homepage = "https://github.com/nu12/dockerapi" spec.license = "MIT" - spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") + spec.required_ruby_version = ">= 3.0" spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = "https://github.com/nu12/dockerapi.git" From e7bb280ba00ec8dd52df4cd3a110cd2da8152b7f Mon Sep 17 00:00:00 2001 From: thomas morgan Date: Tue, 5 Nov 2024 19:01:10 -0700 Subject: [PATCH 5/5] silence warning --- lib/dockerapi.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dockerapi.rb b/lib/dockerapi.rb index 838552a..b1cf87b 100644 --- a/lib/dockerapi.rb +++ b/lib/dockerapi.rb @@ -43,6 +43,7 @@ def self.print_response_to_stdout def self.print_response_to_stdout=(bool) @@print_response_to_stdout = bool end + self.print_response_to_stdout = false ## # Valid values for parameter validations.