secret_config 0.10.3 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/secret_config/registry.rb +1 -1
- data/lib/secret_config/setting_interpolator.rb +12 -0
- data/lib/secret_config/version.rb +1 -1
- data/test/setting_interpolator_test.rb +22 -0
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c448ac94d8b53e13027c3b4df10eaea31720ee069f50c3fa6f7feae5743c8b5
|
4
|
+
data.tar.gz: c20fb32c6915115055e2cb651efcac8cfc69d1da88c957f9cf539486174e8d14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12605771be0a30e288d9a4155259207cebf68865cc62b7407bd2174e6303cae095e3ad5b9e50bf02cd7fa9bcce0a3a80454bc2af9629b38316a85e069fa8e7e3
|
7
|
+
data.tar.gz: a002a780853f22cc9919da018f7fd54678121f83e1663cf767e150f4cefcf54c6b1d96c5a15601ee688c8c2d062ae9883edafa5070d5faefd234b6f8d913ee2d
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Secret Config
|
2
|
-
[![Gem Version](https://img.shields.io/gem/v/secret_config.svg)](https://rubygems.org/gems/secret_config) [![Build Status](https://
|
2
|
+
[![Gem Version](https://img.shields.io/gem/v/secret_config.svg)](https://rubygems.org/gems/secret_config) [![Build Status](https://github.com/rocketjob/secret_config/workflows/build/badge.svg)](https://github.com/rocketjob/secret_config/actions?query=workflow%3Abuild) [![License](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](http://opensource.org/licenses/Apache-2.0) ![](https://img.shields.io/badge/status-Production%20Ready-blue.svg) [![Gitter chat](https://img.shields.io/badge/IRC%20(gitter)-Support-brightgreen.svg)](https://gitter.im/rocketjob/support)
|
3
3
|
|
4
4
|
Centralized Configuration and Secrets Management for Ruby and Rails applications.
|
5
5
|
|
@@ -17,6 +17,9 @@ require "securerandom"
|
|
17
17
|
# ${pid} # Process Id for this process.
|
18
18
|
# ${random} # URL safe Random 32 byte value.
|
19
19
|
# ${random:size} # URL safe Random value of `size` bytes.
|
20
|
+
# ${select:a,b,c,d} # Randomly select one of the supplied values. A new new value is selected on restart or refresh.
|
21
|
+
# # Values are separated by `,` and cannot include `,` in their values.
|
22
|
+
# # Values are stripped of leading and trailing spaces.
|
20
23
|
module SecretConfig
|
21
24
|
class SettingInterpolator < StringInterpolator
|
22
25
|
def date(format = "%Y%m%d")
|
@@ -48,5 +51,14 @@ module SecretConfig
|
|
48
51
|
def random(size = 32)
|
49
52
|
SecureRandom.urlsafe_base64(size)
|
50
53
|
end
|
54
|
+
|
55
|
+
# Empty values return nil which removes the key entirely from the config
|
56
|
+
def select(*values)
|
57
|
+
if values.size < 2
|
58
|
+
raise(ConfigurationError, "Must supply at least 2 options when using select: #{values.inspect}")
|
59
|
+
end
|
60
|
+
|
61
|
+
values[SecureRandom.random_number(values.count)]
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
@@ -154,6 +154,28 @@ module SecretConfig
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
157
|
+
|
158
|
+
describe "#select" do
|
159
|
+
it "randomly selects one of the supplied values" do
|
160
|
+
string = "${select:one, two,three}"
|
161
|
+
actual = interpolator.parse(string)
|
162
|
+
assert %w[one two three].include?(actual), actual
|
163
|
+
end
|
164
|
+
|
165
|
+
it "fails when less than 2 options are supplied" do
|
166
|
+
string = "${select:one}"
|
167
|
+
assert_raises ConfigurationError do
|
168
|
+
interpolator.parse(string)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
it "fails when no options are supplied" do
|
173
|
+
string = "${select}"
|
174
|
+
assert_raises ConfigurationError do
|
175
|
+
interpolator.parse(string)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
157
179
|
end
|
158
180
|
end
|
159
181
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secret_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -26,7 +26,6 @@ dependencies:
|
|
26
26
|
version: '0'
|
27
27
|
description:
|
28
28
|
email:
|
29
|
-
- reidmo@gmail.com
|
30
29
|
executables:
|
31
30
|
- secret-config
|
32
31
|
extensions: []
|
@@ -59,7 +58,7 @@ files:
|
|
59
58
|
- test/setting_interpolator_test.rb
|
60
59
|
- test/test_helper.rb
|
61
60
|
- test/utils_test.rb
|
62
|
-
homepage: https://
|
61
|
+
homepage: https://config.rocketjob.io
|
63
62
|
licenses:
|
64
63
|
- Apache-2.0
|
65
64
|
metadata: {}
|
@@ -78,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
77
|
- !ruby/object:Gem::Version
|
79
78
|
version: '0'
|
80
79
|
requirements: []
|
81
|
-
rubygems_version: 3.2.
|
80
|
+
rubygems_version: 3.2.22
|
82
81
|
signing_key:
|
83
82
|
specification_version: 4
|
84
83
|
summary: Centralized Configuration and Secrets Management for Ruby and Rails applications.
|