figaro_secrets 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/figaro_secrets.rb +5 -0
- data/lib/figaro_secrets/parser.rb +2 -0
- data/lib/figaro_secrets/version.rb +1 -1
- data/test/figaro_secrets_test.rb +9 -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: 19b37e703c80017d8dd091febb440ac6b6f32ead3b920e5fcbce01c670c4b7ac
|
4
|
+
data.tar.gz: 8ab5d1aebfd09b9f77a12c2faa24d7623d9cd18c22f2e3736f7355d46a93d9d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdf0c93a31bf71f48a81023cf510dc4a3d20b4fbdf8edebffc96495d9cde8014ee4234a7c5ff5f8a99e95096190ce3025124bfb0ec468fafb74f81eb1909320d
|
7
|
+
data.tar.gz: 4012f60a45d75f4c210712ce5f935381eb5b9e77acd830ab20e010d26d1fc94b52acc108c980278fed5c3239cd6cf17fd51db9dcec6869315e6726699a803dbe
|
data/Gemfile.lock
CHANGED
data/lib/figaro_secrets.rb
CHANGED
@@ -11,6 +11,11 @@ module FigaroSecrets
|
|
11
11
|
def self.log_error(message)
|
12
12
|
Rails.logger&.error(message) || $stderr.puts(message)
|
13
13
|
end
|
14
|
+
|
15
|
+
# Short circuit to prevent parsing secrets
|
16
|
+
def self.enabled?
|
17
|
+
ENV["FIGARO_SECRETS"] != "false"
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
21
|
require "figaro_secrets/hook"
|
@@ -5,6 +5,8 @@ module FigaroSecrets
|
|
5
5
|
SECRET_REGEX = /^secretsmanager:(?<secret>.*)/
|
6
6
|
|
7
7
|
def parse_secrets(configuration)
|
8
|
+
return configuration unless FigaroSecrets.enabled?
|
9
|
+
|
8
10
|
configuration.inject({}) do |memo, (key, value)|
|
9
11
|
memo.merge(key => parse_secret(key, value))
|
10
12
|
end
|
data/test/figaro_secrets_test.rb
CHANGED
@@ -2,6 +2,14 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class FigaroSecretsTest < Minitest::Test
|
4
4
|
def test_that_it_has_a_version_number
|
5
|
-
refute_nil
|
5
|
+
refute_nil FigaroSecrets::VERSION
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_enabled?
|
9
|
+
assert_equal true, FigaroSecrets.enabled?
|
10
|
+
original_env = ENV.to_h.dup
|
11
|
+
ENV["FIGARO_SECRETS"] = "false"
|
12
|
+
assert_equal false, FigaroSecrets.enabled?
|
13
|
+
ENV.replace(original_env)
|
6
14
|
end
|
7
15
|
end
|