legion-data 1.10.6 → 1.10.7
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/.rubocop.yml +2 -7
- data/CHANGELOG.md +4 -0
- data/lib/legion/data/connection.rb +20 -0
- data/lib/legion/data/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: bc598e354968c28944d6e897feb5853d57987fed49eaf0cd16f319abcfbd8cf8
|
|
4
|
+
data.tar.gz: ebc17c4d4b8c49585bcdb0a49803c4988e8d55970ddde56b294746d810193f63
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f36631ecd03c493fa2dfd3b347a4f16765b7900545d31306e4b73f0418a455a99c15ab55a8de83ad86c123befede09a222a67a6095f624923028c585ca9c7d0
|
|
7
|
+
data.tar.gz: 9a1783c655df6dce9c23a4a878645cf196e4463d0763d95c380029263a8deeccce7cfce8e66ede4843a04c68e8369232d8d4b785460bd70181d4ad1adcf1c01b
|
data/.rubocop.yml
CHANGED
|
@@ -23,13 +23,6 @@ Naming/VariableNumber:
|
|
|
23
23
|
- lib/legion/data/connection.rb
|
|
24
24
|
Legion/Framework/EagerSequelModel:
|
|
25
25
|
Enabled: false
|
|
26
|
-
# TaxonomyEnum validates LLM lane taxonomy (:tier/:type/:circuit_state). In
|
|
27
|
-
# these paths `type:` is a Sequel column type (e.g. foreign_key type: :uuid) or
|
|
28
|
-
# the extract API (type: :auto/:text) — not LLM taxonomy — so the cop misfires.
|
|
29
|
-
Legion/Llm/TaxonomyEnum:
|
|
30
|
-
Exclude:
|
|
31
|
-
- 'lib/legion/data/migrations/**/*'
|
|
32
|
-
- 'spec/**/*'
|
|
33
26
|
Metrics/BlockLength:
|
|
34
27
|
Max: 100
|
|
35
28
|
Exclude:
|
|
@@ -37,6 +30,8 @@ Metrics/BlockLength:
|
|
|
37
30
|
- 'lib/legion/data/migrations/*'
|
|
38
31
|
ThreadSafety/ClassInstanceVariable:
|
|
39
32
|
Enabled: false
|
|
33
|
+
Legion/Llm/TaxonomyEnum:
|
|
34
|
+
Enabled: false
|
|
40
35
|
ThreadSafety/ClassAndModuleAttributes:
|
|
41
36
|
Enabled: false
|
|
42
37
|
Metrics/AbcSize:
|
data/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,10 @@ module Legion
|
|
|
10
10
|
module Connection
|
|
11
11
|
ADAPTERS = %i[sqlite mysql2 postgres].freeze
|
|
12
12
|
|
|
13
|
+
UNRESOLVED_URI_PATTERN = %r{\A(?:vault|env|lease)://}
|
|
14
|
+
|
|
15
|
+
class UnresolvedCredentialError < StandardError; end
|
|
16
|
+
|
|
13
17
|
GENERIC_KEYS = %i[max_connections pool_timeout preconnect single_threaded test name].freeze
|
|
14
18
|
|
|
15
19
|
ADAPTER_KEYS = {
|
|
@@ -171,6 +175,9 @@ module Legion
|
|
|
171
175
|
attempted_adapter = adapter
|
|
172
176
|
begin
|
|
173
177
|
::Sequel.connect(connection_opts_for(adapter: attempted_adapter, opts: opts))
|
|
178
|
+
rescue UnresolvedCredentialError => e
|
|
179
|
+
handle_exception(e, level: :fatal, handled: false, operation: :data_connect)
|
|
180
|
+
raise
|
|
174
181
|
rescue StandardError => e
|
|
175
182
|
raise unless dev_fallback?
|
|
176
183
|
|
|
@@ -410,10 +417,23 @@ module Legion
|
|
|
410
417
|
|
|
411
418
|
def connection_opts_for(adapter:, opts:)
|
|
412
419
|
connection_opts = opts.merge(adapter: adapter, **creds_builder)
|
|
420
|
+
validate_no_unresolved_uris!(connection_opts)
|
|
413
421
|
connection_opts[:preconnect] = false if adapter != :sqlite && dev_fallback?
|
|
414
422
|
connection_opts
|
|
415
423
|
end
|
|
416
424
|
|
|
425
|
+
def validate_no_unresolved_uris!(connection_opts)
|
|
426
|
+
%i[user username password].each do |key|
|
|
427
|
+
value = connection_opts[key]
|
|
428
|
+
next unless value.is_a?(String) && value.match?(UNRESOLVED_URI_PATTERN)
|
|
429
|
+
|
|
430
|
+
raise UnresolvedCredentialError,
|
|
431
|
+
"Legion::Data cannot connect: settings[:data][:creds][:#{key}] is still " \
|
|
432
|
+
"an unresolved URI placeholder (#{value}). The settings resolver failed to " \
|
|
433
|
+
'resolve this lease — check that Legion::Crypt and Vault are available at boot.'
|
|
434
|
+
end
|
|
435
|
+
end
|
|
436
|
+
|
|
417
437
|
def sequel_opts
|
|
418
438
|
data = Legion::Settings[:data]
|
|
419
439
|
opts = {}
|
data/lib/legion/data/version.rb
CHANGED