anyway_config 2.6.4 → 2.7.1
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 +21 -0
- data/README.md +5 -3
- data/lib/.rbnext/2.7/anyway/config.rb +2 -0
- data/lib/.rbnext/2.7/anyway/settings.rb +7 -1
- data/lib/.rbnext/2.7/anyway/type_casting.rb +4 -0
- data/lib/.rbnext/3.0/anyway/config.rb +2 -0
- data/lib/.rbnext/3.1/anyway/config.rb +2 -0
- data/lib/.rbnext/3.2/anyway/config.rb +2 -0
- data/lib/.rbnext/3.4/anyway/config.rb +2 -0
- data/lib/.rbnext/3.4/anyway/type_casting.rb +4 -0
- data/lib/anyway/config.rb +2 -0
- data/lib/anyway/rails/settings.rb +12 -1
- data/lib/anyway/settings.rb +7 -1
- data/lib/anyway/type_casting.rb +4 -0
- data/lib/anyway/version.rb +1 -1
- data/lib/rails/commands/local_credentials/local_credentials_command.rb +7 -0
- data/sig/anyway_config.rbs +1 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6e808e00b7756aa1b22f20792dfcfbc5989c5f41a88ae5b16e87ee3e556b17d
|
4
|
+
data.tar.gz: ef819a44f7ac000f206929dbb412f778130bb40b240c45478e548c582a7b52f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca3f7f4ad799af0c53b613786a5407fa4d41a937528b12d17b69f466f3a7152a3b89e61cbcd4112f9bfd69b26089d3223eb85ba68859f9173997636ff04626a6
|
7
|
+
data.tar.gz: '00762802a9a92438cfd3ef29681eebaad657a81ddda44a06799c39c4f024d3975458b3380b8ef7b97611d9d561476a7fab386aa636aaa0a6712491790a583919'
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 2.7.1 (2025-02-24)
|
6
|
+
|
7
|
+
- Suppress required validations when running Rails credentials commands. ([@palkan][])
|
8
|
+
|
9
|
+
## 2.7.0 (2025-02-12)
|
10
|
+
|
11
|
+
- Added `suppress_required_validations` configuration for skipping validation in CI. ([@OlegChuev][])
|
12
|
+
|
13
|
+
- Support for the Rails built-in environment variable `SECRET_KEY_BASE_DUMMY`. If this variable is set, all validations for required attributes are skipped. This is particularly useful for executing `bundle exec rails assets:precompile` in CI/CD pipelines. ([@OlegChuev][])
|
14
|
+
|
15
|
+
- Introduced a global setting `Anyway::Settings.suppress_required_validations = true` to disable validations. This can be toggled via the environment variable `ANYWAY_SUPPRESS_VALIDATIONS`. Please note, `ANYWAY_SUPPRESS_VALIDATIONS` takes precedence over `SECRET_KEY_BASE_DUMMY`.
|
16
|
+
|
17
|
+
- Added `:integer!` type support (strong integer coercion). ([@klondaiker][])
|
18
|
+
|
19
|
+
- Fix handling relative vs. absolute paths in `autoload_static_configs_path=`. ([@palkan][])
|
20
|
+
|
21
|
+
- Fix support for array values in `except` option for required attributes. ([@dominikb][])
|
22
|
+
|
5
23
|
## 2.6.4 (2024-04-30)
|
6
24
|
|
7
25
|
- Fix RBS manifest file name (`.yml` -> `.yaml`). ([@carlqt][])
|
@@ -579,3 +597,6 @@ No we're dependency-free!
|
|
579
597
|
[@tagirahmad]: https://github.com/tagirahmad
|
580
598
|
[@bessey]: https://github.com/bessey
|
581
599
|
[@carlqt]: https://github.com/carlqt
|
600
|
+
[@OlegChuev]: https://github.com/OlegChuev
|
601
|
+
[@dominikb]: https://github.com/dominikb
|
602
|
+
[@klondaiker]: https://github.com/klondaiker
|
data/README.md
CHANGED
@@ -73,7 +73,7 @@ end
|
|
73
73
|
|
74
74
|
Using Ruby classes to represent configuration allows you to add helper methods and computed parameters easily, makes the configuration **testable**.
|
75
75
|
|
76
|
-
The `anyway_config` gem takes care of loading parameters from **different sources** (YAML, credentials
|
76
|
+
The `anyway_config` gem takes care of loading parameters from **different sources** (YAML, credentials, environment variables, etc.). Internally, we use a _pipeline pattern_ and provide the [Loaders API](#data-loaders) to manage and [extend](#custom-loaders) its functionality.
|
77
77
|
|
78
78
|
Check out the libraries using Anyway Config for more examples:
|
79
79
|
|
@@ -270,7 +270,6 @@ This feature is similar to `Rails.application.config_for` but more powerful:
|
|
270
270
|
| Feature | Rails | Anyway Config |
|
271
271
|
| ------------- |-------------:| -----:|
|
272
272
|
| Load data from `config/app.yml` | ✅ | ✅ |
|
273
|
-
| Load data from `secrets` | ❌ | ✅ |
|
274
273
|
| Load data from `credentials` | ❌ | ✅ |
|
275
274
|
| Load data from environment | ❌ | ✅ |
|
276
275
|
| Load data from [other sources](#data-loaders) | ❌ | ✅ |
|
@@ -304,6 +303,9 @@ MyConfig.new(api_secret: "") #=> raises Anyway::Config::ValidationError
|
|
304
303
|
`Required` method supports additional `env` parameter which indicates necessity to run validations under specified
|
305
304
|
environments. `Env` parameter could be present in symbol, string, array or hash formats:
|
306
305
|
|
306
|
+
**NOTE:** You can suppress the validation of the required parameters (it can be useful for CI) via the `ANYWAY_SUPPRESS_VALIDATIONS` environment variable or by setting it explicitly in the code: `Anyway::Settings.suppress_required_validations = true`.
|
307
|
+
If you are using Anyway Config with Rails and have already specified `SECRET_KEY_BASE_DUMMY` for asset pre compilation, validation will be skipped by default.
|
308
|
+
|
307
309
|
```ruby
|
308
310
|
class EnvConfig < Anyway::Config
|
309
311
|
required :password, env: "production"
|
@@ -712,7 +714,7 @@ CoolConfig.new.port == "443" #=> true
|
|
712
714
|
|
713
715
|
**IMPORTANT**: Values provided explicitly (via attribute writers) are not coerced. Coercion is only happening during the load phase.
|
714
716
|
|
715
|
-
The following types are supported out-of-the-box: `:string`, `:integer`, `:float`, `:date`, `:datetime`, `:uri`, `:boolean`.
|
717
|
+
The following types are supported out-of-the-box: `:string`, `:integer`, `:integer!` (strict integer), `:float`, `:date`, `:datetime`, `:uri`, `:boolean`.
|
716
718
|
|
717
719
|
You can use custom deserializers by passing a callable object instead of a type name:
|
718
720
|
|
@@ -445,6 +445,8 @@ module Anyway # :nodoc:
|
|
445
445
|
attr_reader :values, :__trace__
|
446
446
|
|
447
447
|
def validate_required_attributes!
|
448
|
+
return if Settings.suppress_required_validations
|
449
|
+
|
448
450
|
self.class.required_attributes.select do |name|
|
449
451
|
val = values.dig(*name.to_s.split(".").map(&:to_sym))
|
450
452
|
val.nil? || (val.is_a?(String) && val.empty?)
|
@@ -52,6 +52,9 @@ module Anyway
|
|
52
52
|
:default_environmental_key,
|
53
53
|
:known_environments
|
54
54
|
|
55
|
+
# Suppress required validations for CI/CD pipelines
|
56
|
+
attr_accessor :suppress_required_validations
|
57
|
+
|
55
58
|
# A proc returning a path to YML config file given the config name
|
56
59
|
attr_reader :default_config_path
|
57
60
|
|
@@ -86,7 +89,7 @@ module Anyway
|
|
86
89
|
|
87
90
|
if env.is_a?(::Hash)
|
88
91
|
envs = env[:except]
|
89
|
-
excluded_envs = [envs].flat_map(&:to_s)
|
92
|
+
excluded_envs = [*envs].flat_map(&:to_s)
|
90
93
|
excluded_envs.none?(current_environment)
|
91
94
|
elsif env.is_a?(::Array)
|
92
95
|
env.flat_map(&:to_s).include?(current_environment)
|
@@ -107,5 +110,8 @@ module Anyway
|
|
107
110
|
|
108
111
|
# Tracing is enabled by default
|
109
112
|
self.tracing_enabled = true
|
113
|
+
|
114
|
+
# By default, use ANYWAY_SUPPRESS_VALIDATIONS
|
115
|
+
self.suppress_required_validations = %w[1 t true y yes].include?(ENV["ANYWAY_SUPPRESS_VALIDATIONS"])
|
110
116
|
end
|
111
117
|
end
|
@@ -445,6 +445,8 @@ module Anyway # :nodoc:
|
|
445
445
|
attr_reader :values, :__trace__
|
446
446
|
|
447
447
|
def validate_required_attributes!
|
448
|
+
return if Settings.suppress_required_validations
|
449
|
+
|
448
450
|
self.class.required_attributes.select do |name|
|
449
451
|
val = values.dig(*name.to_s.split(".").map(&:to_sym))
|
450
452
|
val.nil? || (val.is_a?(String) && val.empty?)
|
@@ -445,6 +445,8 @@ module Anyway # :nodoc:
|
|
445
445
|
attr_reader :values, :__trace__
|
446
446
|
|
447
447
|
def validate_required_attributes!
|
448
|
+
return if Settings.suppress_required_validations
|
449
|
+
|
448
450
|
self.class.required_attributes.select do |name|
|
449
451
|
val = values.dig(*name.to_s.split(".").map(&:to_sym))
|
450
452
|
val.nil? || (val.is_a?(String) && val.empty?)
|
@@ -445,6 +445,8 @@ module Anyway # :nodoc:
|
|
445
445
|
attr_reader :values, :__trace__
|
446
446
|
|
447
447
|
def validate_required_attributes!
|
448
|
+
return if Settings.suppress_required_validations
|
449
|
+
|
448
450
|
self.class.required_attributes.select do |name|
|
449
451
|
val = values.dig(*name.to_s.split(".").map(&:to_sym))
|
450
452
|
val.nil? || (val.is_a?(String) && val.empty?)
|
@@ -445,6 +445,8 @@ module Anyway # :nodoc:
|
|
445
445
|
attr_reader :values, :__trace__
|
446
446
|
|
447
447
|
def validate_required_attributes!
|
448
|
+
return if Settings.suppress_required_validations
|
449
|
+
|
448
450
|
self.class.required_attributes.select do |name|
|
449
451
|
val = values.dig(*name.to_s.split(".").map(&:to_sym))
|
450
452
|
val.nil? || (val.is_a?(String) && val.empty?)
|
data/lib/anyway/config.rb
CHANGED
@@ -445,6 +445,8 @@ module Anyway # :nodoc:
|
|
445
445
|
attr_reader :values, :__trace__
|
446
446
|
|
447
447
|
def validate_required_attributes!
|
448
|
+
return if Settings.suppress_required_validations
|
449
|
+
|
448
450
|
self.class.required_attributes.select do |name|
|
449
451
|
val = values.dig(*name.to_s.split(".").map(&:to_sym))
|
450
452
|
val.nil? || (val.is_a?(String) && val.empty?)
|
@@ -19,7 +19,7 @@ module Anyway
|
|
19
19
|
|
20
20
|
return unless ::Rails.root.join(val).exist?
|
21
21
|
|
22
|
-
return if val == autoload_static_config_path
|
22
|
+
return if ::Rails.root.join(val.to_s) == ::Rails.root.join(autoload_static_config_path.to_s)
|
23
23
|
|
24
24
|
autoloader&.unload
|
25
25
|
|
@@ -79,5 +79,16 @@ module Anyway
|
|
79
79
|
self.use_local_files ||= ::Rails.env.development?
|
80
80
|
# Don't try read defaults when no key defined
|
81
81
|
self.default_environmental_key = nil
|
82
|
+
|
83
|
+
self.suppress_required_validations = ENV.key?("SECRET_KEY_BASE_DUMMY") unless ENV.key?("ANYWAY_SUPPRESS_VALIDATIONS")
|
84
|
+
|
85
|
+
# Suppress validations when working with credentials
|
86
|
+
if defined?(::Rails::Command::CredentialsCommand) && ::Rails::Command.respond_to?(:const_source_location)
|
87
|
+
credentials_source_path = ::Rails::Command.const_source_location("CredentialsCommand").first
|
88
|
+
|
89
|
+
if caller_locations.any? { |l| l.absolute_path == credentials_source_path }
|
90
|
+
self.suppress_required_validations = true
|
91
|
+
end
|
92
|
+
end
|
82
93
|
end
|
83
94
|
end
|
data/lib/anyway/settings.rb
CHANGED
@@ -52,6 +52,9 @@ module Anyway
|
|
52
52
|
:default_environmental_key,
|
53
53
|
:known_environments
|
54
54
|
|
55
|
+
# Suppress required validations for CI/CD pipelines
|
56
|
+
attr_accessor :suppress_required_validations
|
57
|
+
|
55
58
|
# A proc returning a path to YML config file given the config name
|
56
59
|
attr_reader :default_config_path
|
57
60
|
|
@@ -86,7 +89,7 @@ module Anyway
|
|
86
89
|
|
87
90
|
if env.is_a?(::Hash)
|
88
91
|
envs = env[:except]
|
89
|
-
excluded_envs = [envs].flat_map(&:to_s)
|
92
|
+
excluded_envs = [*envs].flat_map(&:to_s)
|
90
93
|
excluded_envs.none?(current_environment)
|
91
94
|
elsif env.is_a?(::Array)
|
92
95
|
env.flat_map(&:to_s).include?(current_environment)
|
@@ -107,5 +110,8 @@ module Anyway
|
|
107
110
|
|
108
111
|
# Tracing is enabled by default
|
109
112
|
self.tracing_enabled = true
|
113
|
+
|
114
|
+
# By default, use ANYWAY_SUPPRESS_VALIDATIONS
|
115
|
+
self.suppress_required_validations = %w[1 t true y yes].include?(ENV["ANYWAY_SUPPRESS_VALIDATIONS"])
|
110
116
|
end
|
111
117
|
end
|
data/lib/anyway/type_casting.rb
CHANGED
data/lib/anyway/version.rb
CHANGED
data/sig/anyway_config.rbs
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anyway_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-next-core
|
@@ -206,7 +206,7 @@ metadata:
|
|
206
206
|
homepage_uri: http://github.com/palkan/anyway_config
|
207
207
|
source_code_uri: http://github.com/palkan/anyway_config
|
208
208
|
funding_uri: https://github.com/sponsors/palkan
|
209
|
-
post_install_message:
|
209
|
+
post_install_message:
|
210
210
|
rdoc_options: []
|
211
211
|
require_paths:
|
212
212
|
- lib
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
version: '0'
|
223
223
|
requirements: []
|
224
224
|
rubygems_version: 3.4.19
|
225
|
-
signing_key:
|
225
|
+
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Configuration DSL for Ruby libraries and applications
|
228
228
|
test_files: []
|