getaround_utils 0.3.3 → 0.3.4
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 +22 -0
- data/Gemfile.lock +1 -1
- data/README.md +11 -9
- data/lib/getaround_utils/utils/config_url.rb +10 -6
- data/lib/getaround_utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a0b5e64b0be84ffcfe22850f5b73c5e6d08d7eb6d843e7792d35268626377c7
|
|
4
|
+
data.tar.gz: 9dcefce00a8ad7bbb89ed28e6e4264c3ba80139ef9c2d2e0ade8f9fe0fe739c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dff6641aa462aaf39e532b023723e25f1d8af1bc9fcaa1b24a5ea7b896910788c5f7c66121940281474d760dbf7e9d08f7a7fd2234e777cf08964c433283b83a
|
|
7
|
+
data.tar.gz: 63b26fa1260b94a4884d49bd42ce0aeb13fd3c1c0b3b03fa31863d214e2ff323530de7315dd7843ba5dbb54b3bf8d2957efa90d51644c4a3c147aca1178e3860
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [0.3.4] 2026-02-27
|
|
2
|
+
|
|
3
|
+
### Breaking Changes
|
|
4
|
+
|
|
5
|
+
- `GetaroundUtils::Utils::ConfigUrl.from_env` ([#460](https://github.com/drivy/backend-configs/pull/460))
|
|
6
|
+
- Add `_USERNAME` variable support
|
|
7
|
+
- Make sub variables overriding base url segments
|
|
8
|
+
```dotenv
|
|
9
|
+
TEST_URL="whatever://foo:my-pwd@localhost:666/test"
|
|
10
|
+
TEST_USERNAME="bar"
|
|
11
|
+
TEST_PASSWORD="new-pwd"
|
|
12
|
+
```
|
|
13
|
+
```ruby
|
|
14
|
+
# BEFORE (<= 0.3.3)
|
|
15
|
+
GetaroundUtils::Utils::ConfigUrl.from_env('TEST')
|
|
16
|
+
# => <URI::Generic whatever://foo:my-pwd@localhost:666/test>
|
|
17
|
+
|
|
18
|
+
# AFTER (> 0.3.3)
|
|
19
|
+
GetaroundUtils::Utils::ConfigUrl.from_env('TEST')
|
|
20
|
+
# => <URI::Generic whatever://bar:new-pwd@localhost:666/test>
|
|
21
|
+
```
|
|
22
|
+
|
|
1
23
|
## [0.3.3] 2026-02-27
|
|
2
24
|
- `GetaroundUtils::I18nBackend::FlatKeys` should be a module
|
|
3
25
|
|
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')
|
|
@@ -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
|