Skip to content

Commit 8015918

Browse files
authored
Merge pull request #8 from Hexlet/release-please--branches--main--changes--next
release: 0.5.0
2 parents 8ec174a + 80d5de5 commit 8015918

File tree

10 files changed

+65
-9
lines changed

10 files changed

+65
-9
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.4.0"
2+
".": "0.5.0"
33
}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 102
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hexlet%2Fdocker-31f80d10d31a27ca7945346411d6914e4b67a36769e006cb922d2cd7214c6ecc.yml
3-
openapi_spec_hash: f79f7bd46f2d82f5f60481696d782b7c
4-
config_hash: 5e86cccf228162276328f1b5ced3b7d0
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hexlet%2Fdocker-7dbd508c79cf09803a2a05ee36b55ae9219a6218f0637891b33e1ac25db10b5d.yml
3+
openapi_spec_hash: 16948cc9b83def4e333889ca4e0497f3
4+
config_hash: a6764d7382ab85291261b00542e66610

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.5.0 (2026-02-14)
4+
5+
Full Changelog: [v0.4.0...v0.5.0](https://github.com/Hexlet/docker-ruby/compare/v0.4.0...v0.5.0)
6+
7+
### Features
8+
9+
* **api:** api update ([a44163c](https://github.com/Hexlet/docker-ruby/commit/a44163cdccd707282795ba0dfccc5c8647bb42ce))
10+
311
## 0.4.0 (2026-02-14)
412

513
Full Changelog: [v0.3.0...v0.4.0](https://github.com/Hexlet/docker-ruby/compare/v0.3.0...v0.4.0)

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GIT
1111
PATH
1212
remote: .
1313
specs:
14-
docker-engine-ruby (0.4.0)
14+
docker-engine-ruby (0.5.0)
1515
cgi
1616
connection_pool
1717

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
1717
<!-- x-release-please-start-version -->
1818

1919
```ruby
20-
gem "docker-engine-ruby", "~> 0.4.0"
20+
gem "docker-engine-ruby", "~> 0.5.0"
2121
```
2222

2323
<!-- x-release-please-end -->
@@ -28,7 +28,9 @@ gem "docker-engine-ruby", "~> 0.4.0"
2828
require "bundler/setup"
2929
require "docker_engine_ruby"
3030

31-
docker = DockerEngineRuby::Client.new
31+
docker = DockerEngineRuby::Client.new(
32+
environment: "production_tls" # defaults to "production"
33+
)
3234

3335
create_response = docker.containers.create(name: "sample-container")
3436

lib/docker_engine_ruby/client.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ class Client < DockerEngineRuby::Internal::Transport::BaseClient
1515
# Default max retry delay in seconds.
1616
DEFAULT_MAX_RETRY_DELAY = 8.0
1717

18+
# rubocop:disable Style/MutableConstant
19+
# @type [Hash{Symbol=>String}]
20+
ENVIRONMENTS = {production: "http://localhost:2375", production_tls: "https://localhost:2376"}
21+
# rubocop:enable Style/MutableConstant
22+
1823
# @return [DockerEngineRuby::Resources::Auth]
1924
attr_reader :auth
2025

@@ -62,6 +67,13 @@ class Client < DockerEngineRuby::Internal::Transport::BaseClient
6267

6368
# Creates and returns a new client for interacting with the API.
6469
#
70+
# @param environment [:production, :production_tls, nil] Specifies the environment to use for the API.
71+
#
72+
# Each environment maps to a different base URL:
73+
#
74+
# - `production` corresponds to `http://localhost:2375`
75+
# - `production_tls` corresponds to `https://localhost:2376`
76+
#
6577
# @param base_url [String, nil] Override the default base URL for the API, e.g.,
6678
# `"https://api.example.com/v2/"`. Defaults to `ENV["DOCKER_BASE_URL"]`
6779
#
@@ -73,13 +85,17 @@ class Client < DockerEngineRuby::Internal::Transport::BaseClient
7385
#
7486
# @param max_retry_delay [Float]
7587
def initialize(
88+
environment: nil,
7689
base_url: ENV["DOCKER_BASE_URL"],
7790
max_retries: self.class::DEFAULT_MAX_RETRIES,
7891
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
7992
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
8093
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
8194
)
82-
base_url ||= "http://localhost:2375"
95+
base_url ||= DockerEngineRuby::Client::ENVIRONMENTS.fetch(environment&.to_sym || :production) do
96+
message = "environment must be one of #{DockerEngineRuby::Client::ENVIRONMENTS.keys}, got #{environment}"
97+
raise ArgumentError.new(message)
98+
end
8399

84100
super(
85101
base_url: base_url,

lib/docker_engine_ruby/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module DockerEngineRuby
4-
VERSION = "0.4.0"
4+
VERSION = "0.5.0"
55
end

rbi/docker_engine_ruby/client.rbi

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ module DockerEngineRuby
1010

1111
DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float)
1212

13+
ENVIRONMENTS =
14+
T.let(
15+
{
16+
production: "http://localhost:2375",
17+
production_tls: "https://localhost:2376"
18+
},
19+
T::Hash[Symbol, String]
20+
)
21+
1322
sig { returns(DockerEngineRuby::Resources::Auth) }
1423
attr_reader :auth
1524

@@ -58,6 +67,7 @@ module DockerEngineRuby
5867
# Creates and returns a new client for interacting with the API.
5968
sig do
6069
params(
70+
environment: T.nilable(T.any(Symbol, String)),
6171
base_url: T.nilable(String),
6272
max_retries: Integer,
6373
timeout: Float,
@@ -66,6 +76,13 @@ module DockerEngineRuby
6676
).returns(T.attached_class)
6777
end
6878
def self.new(
79+
# Specifies the environment to use for the API.
80+
#
81+
# Each environment maps to a different base URL:
82+
#
83+
# - `production` corresponds to `http://localhost:2375`
84+
# - `production_tls` corresponds to `https://localhost:2376`
85+
environment: nil,
6986
# Override the default base URL for the API, e.g.,
7087
# `"https://api.example.com/v2/"`. Defaults to `ENV["DOCKER_BASE_URL"]`
7188
base_url: ENV["DOCKER_BASE_URL"],

sig/docker_engine_ruby/client.rbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ module DockerEngineRuby
88

99
DEFAULT_MAX_RETRY_DELAY: Float
1010

11+
ENVIRONMENTS: {
12+
production: "http://localhost:2375",
13+
production_tls: "https://localhost:2376"
14+
}
15+
1116
attr_reader auth: DockerEngineRuby::Resources::Auth
1217

1318
attr_reader system_: DockerEngineRuby::Resources::System
@@ -39,6 +44,7 @@ module DockerEngineRuby
3944
attr_reader distribution: DockerEngineRuby::Resources::Distribution
4045

4146
def initialize: (
47+
?environment: :production | :production_tls | nil,
4248
?base_url: String?,
4349
?max_retries: Integer,
4450
?timeout: Float,

test/docker_engine_ruby/client_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ def after_all
2727
super
2828
end
2929

30+
def test_raises_on_unknown_environment
31+
e = assert_raises(ArgumentError) do
32+
DockerEngineRuby::Client.new(environment: "wrong")
33+
end
34+
assert_match(/environment must be one of/, e.message)
35+
end
36+
3037
def test_client_default_request_default_retry_attempts
3138
stub_request(:get, "http://localhost/containers/json").to_return_json(status: 500, body: {})
3239

0 commit comments

Comments
 (0)