getaround_utils 0.3.3 → 0.3.5
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 +39 -0
- data/Gemfile.lock +1 -1
- data/README.md +27 -9
- data/lib/getaround_utils/utils/config_url.rb +10 -6
- data/lib/getaround_utils/utils/handle_error.rb +1 -1
- data/lib/getaround_utils/utils/health_check_file.rb +40 -0
- data/lib/getaround_utils/utils.rb +1 -0
- data/lib/getaround_utils/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 197707c0b85b1de9d759389ce44867114b3a1e1bf231e72c23b40356040df563
|
|
4
|
+
data.tar.gz: 36109e28f921a5e8c97fd3f1512b0e2838f6416c2a7b1cd845d3e8784db14cd1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 451a09d17a3aa284e26c1b2700891a4a8df4e5d3a5f7819e7e425c7f6e4c0988471b1cb05df8fd4f1399e45f441e83674a3e3421d9e2b0239e9dace98981ca32
|
|
7
|
+
data.tar.gz: 8e0f3e45775ea0fd26f5d22603870f5f86f71963f0cbacbb88cf5fd46722a6202392825188cff9731a4202c8b85b52c849f23d7a61ce46aacaa0a9a0c349af1d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
## [0.3.5] 2026-07-07
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
- `GetaroundUtils::Utils::HandleError`: notify Bugsnag only when `BUGSNAG_API_KEY` is configured, otherwise log.
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `GetaroundUtils::Utils::HealthCheckFile` ([#481](https://github.com/drivy/backend-configs/pull/481))
|
|
10
|
+
```ruby
|
|
11
|
+
SIDEKIQ_HEALTH_FILE = GetaroundUtils::Utils::HealthCheckFile.new('sidekiq')
|
|
12
|
+
Sidekiq.configure_server do |config|
|
|
13
|
+
config.on(:startup) { SIDEKIQ_HEALTH_FILE.create }
|
|
14
|
+
config.on(:shutdown) { SIDEKIQ_HEALTH_FILE.delete }
|
|
15
|
+
end
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## [0.3.4] 2026-02-27
|
|
19
|
+
|
|
20
|
+
### Breaking Changes
|
|
21
|
+
|
|
22
|
+
- `GetaroundUtils::Utils::ConfigUrl.from_env` ([#460](https://github.com/drivy/backend-configs/pull/460))
|
|
23
|
+
- Add `_USERNAME` variable support
|
|
24
|
+
- Make sub variables overriding base url segments
|
|
25
|
+
```dotenv
|
|
26
|
+
TEST_URL="whatever://foo:my-pwd@localhost:666/test"
|
|
27
|
+
TEST_USERNAME="bar"
|
|
28
|
+
TEST_PASSWORD="new-pwd"
|
|
29
|
+
```
|
|
30
|
+
```ruby
|
|
31
|
+
# BEFORE (<= 0.3.3)
|
|
32
|
+
GetaroundUtils::Utils::ConfigUrl.from_env('TEST')
|
|
33
|
+
# => <URI::Generic whatever://foo:my-pwd@localhost:666/test>
|
|
34
|
+
|
|
35
|
+
# AFTER (> 0.3.3)
|
|
36
|
+
GetaroundUtils::Utils::ConfigUrl.from_env('TEST')
|
|
37
|
+
# => <URI::Generic whatever://bar:new-pwd@localhost:666/test>
|
|
38
|
+
```
|
|
39
|
+
|
|
1
40
|
## [0.3.3] 2026-02-27
|
|
2
41
|
- `GetaroundUtils::I18nBackend::FlatKeys` should be a module
|
|
3
42
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -147,23 +147,25 @@ For more details, [read the spec](spec/getaround_utils/utils/deep_key_value_spec
|
|
|
147
147
|
|
|
148
148
|
### GetaroundUtils::Utils::ConfigUrl
|
|
149
149
|
|
|
150
|
-
This helper allows to manage configuration urls with password extracted in
|
|
150
|
+
This helper allows to manage configuration urls with username and password extracted in dedicated variables.
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
Uses `*_URL` variable and tries to compute `*_USERNAME` and `*_PASSWORD` variables inside the parsed url.
|
|
153
153
|
|
|
154
|
+
```dotenv
|
|
155
|
+
FOO_URL="redis://foo@localhost:666/10"
|
|
156
|
+
FOO_PASSWORD="added-pwd"
|
|
157
|
+
BAR_URL="whatever://bar:baz@localhost:666/42"
|
|
158
|
+
BAR_USERNAME="user666"
|
|
159
|
+
BAR_PASSWORD="new-pwd"
|
|
160
|
+
ENV_TEST_NUMBER=1
|
|
161
|
+
```
|
|
154
162
|
```ruby
|
|
155
|
-
# FOO_URL="redis://foo@localhost:666/10"
|
|
156
|
-
# FOO_PASSWORD="added-pwd"
|
|
157
|
-
# BAR_URL="whatever://bar:used-pwd@localhost:666/42"
|
|
158
|
-
# BAR_PASSWORD="not-used-pwd"
|
|
159
|
-
# ENV_TEST_NUMBER=1
|
|
160
|
-
|
|
161
163
|
GetaroundUtils::Utils::ConfigUrl
|
|
162
164
|
.from_env('FOO')
|
|
163
165
|
.tap { |uri| uri.path += ENV['ENV_TEST_NUMBER'] }
|
|
164
166
|
# => <URI::Generic redis://foo:added-pwd@localhost:666/101>
|
|
165
167
|
GetaroundUtils::Utils::ConfigUrl.from_env('BAR').to_s
|
|
166
|
-
# => "whatever://
|
|
168
|
+
# => "whatever://user666:new-pwd@localhost:666/42"
|
|
167
169
|
GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN')
|
|
168
170
|
# => KeyError: key not found "UNKNOWN_URL"
|
|
169
171
|
GetaroundUtils::Utils::ConfigUrl.from_env('UNKNOWN', 'mysql://localhost/test')
|
|
@@ -197,3 +199,19 @@ end
|
|
|
197
199
|
```
|
|
198
200
|
|
|
199
201
|
For more details, [read the spec](spec/getaround_utils/utils/handle_error_spec.rb)
|
|
202
|
+
|
|
203
|
+
### GetaroundUtils::Utils::HealthCheckFile
|
|
204
|
+
|
|
205
|
+
Helper to easily create health check file used for Kubernetes Probes (Sidekiq, Captur, etc...)
|
|
206
|
+
|
|
207
|
+
*Example in `config/initializers/sidekiq.rb`*
|
|
208
|
+
```ruby
|
|
209
|
+
SIDEKIQ_HEALTH_FILE = GetaroundUtils::Utils::HealthCheckFile.new('sidekiq')
|
|
210
|
+
|
|
211
|
+
Sidekiq.configure_server do |config|
|
|
212
|
+
config.on(:startup) { SIDEKIQ_HEALTH_FILE.create }
|
|
213
|
+
config.on(:shutdown) { SIDEKIQ_HEALTH_FILE.delete }
|
|
214
|
+
end
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
For more details, [read the spec](spec/getaround_utils/utils/health_check_file_spec.rb)
|
|
@@ -9,15 +9,19 @@ module GetaroundUtils::Utils; end
|
|
|
9
9
|
module GetaroundUtils::Utils::ConfigUrl
|
|
10
10
|
def self.from_env(config_name, ...)
|
|
11
11
|
env_url = ENV.fetch("#{config_name}_URL", ...)
|
|
12
|
+
env_usr = ENV.fetch("#{config_name}_USERNAME", nil)
|
|
12
13
|
env_pwd = ENV.fetch("#{config_name}_PASSWORD", nil)
|
|
13
|
-
return if env_url.nil?
|
|
14
|
+
return if env_url.nil? || env_url.empty? # rubocop:disable Rails/Blank
|
|
14
15
|
|
|
15
16
|
::URI.parse(env_url).tap do |uri|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
uri_usr, uri_pwd = uri.userinfo&.split(':', 2)
|
|
18
|
+
uri_pwd = uri_pwd.to_s if uri.userinfo&.include?(':')
|
|
19
|
+
usr = env_usr.nil? ? uri_usr : env_usr
|
|
20
|
+
pwd = env_pwd.nil? ? uri_pwd : env_pwd
|
|
21
|
+
userinfo = usr.to_s
|
|
22
|
+
userinfo += ":#{pwd}" unless pwd.nil?
|
|
23
|
+
|
|
24
|
+
uri.userinfo = userinfo unless userinfo.empty?
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
end
|
|
@@ -11,7 +11,7 @@ module GetaroundUtils::Utils::HandleError
|
|
|
11
11
|
|
|
12
12
|
# @see https://docs.bugsnag.com/platforms/ruby/rails/reporting-handled-errors/#sending-custom-diagnostics
|
|
13
13
|
def self.notify_of(error, **metadata, &)
|
|
14
|
-
if defined?(::Bugsnag)
|
|
14
|
+
if defined?(::Bugsnag) && ::Bugsnag.configuration.api_key
|
|
15
15
|
::Bugsnag.notify(error) do |event|
|
|
16
16
|
metadata.each do |name, value|
|
|
17
17
|
if value.is_a?(Hash)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
|
|
6
|
+
module GetaroundUtils; end
|
|
7
|
+
|
|
8
|
+
module GetaroundUtils::Utils; end
|
|
9
|
+
|
|
10
|
+
class GetaroundUtils::Utils::HealthCheckFile
|
|
11
|
+
FILE_NAME = 'health_check_file'
|
|
12
|
+
|
|
13
|
+
attr_reader :path
|
|
14
|
+
|
|
15
|
+
def initialize(name)
|
|
16
|
+
raise ArgumentError, "Expected name as String, got: #{name.inspect}" if !name.is_a?(String) || name.empty?
|
|
17
|
+
|
|
18
|
+
@base_path = root_path.join('tmp', name)
|
|
19
|
+
@path = @base_path.join(FILE_NAME)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create
|
|
23
|
+
FileUtils.mkdir_p(@base_path)
|
|
24
|
+
FileUtils.touch(@path)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def delete
|
|
28
|
+
FileUtils.rm_f(@path)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def exists?
|
|
32
|
+
File.exist?(@path)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def root_path
|
|
38
|
+
defined?(::Rails) ? Rails.root : Pathname.new('/')
|
|
39
|
+
end
|
|
40
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: getaround_utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Drivy
|
|
@@ -222,6 +222,7 @@ files:
|
|
|
222
222
|
- lib/getaround_utils/utils/config_url.rb
|
|
223
223
|
- lib/getaround_utils/utils/deep_key_value.rb
|
|
224
224
|
- lib/getaround_utils/utils/handle_error.rb
|
|
225
|
+
- lib/getaround_utils/utils/health_check_file.rb
|
|
225
226
|
- lib/getaround_utils/version.rb
|
|
226
227
|
homepage: https://github.com/drivy
|
|
227
228
|
licenses:
|