redis_env_config 0.2.0 → 0.2.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/lib/redis_env_config.rb +14 -4
- data/lib/redis_env_config/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: 9a7711d7e6e5264858d741615d79a27e8467537a386dfad533e0a0974516f21c
|
4
|
+
data.tar.gz: 4c930d355310b7a345ac822d0c5a933d94a71133718824771d952512d8b0798a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aebc053fbff250e16fd8f158c1c42e36193dd28fb498a46bfa31ce2f8759e0343fafae585e63c2a0cdf04a72ddf700c9da0307bb6b4b057277c535d429f57d6
|
7
|
+
data.tar.gz: 6636ea77b07d90b4b568f6f12ec121c32c94f7064657005550368b97e83a03d68c6a2ab3780242b28c9a2fa45653d6707b07ffea7c0c7a19ad659fe256bfb0eb
|
data/lib/redis_env_config.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "redis_env_config/version"
|
2
|
-
require "redis"
|
3
2
|
|
4
3
|
class RedisEnvConfig
|
5
4
|
class Error < StandardError; end
|
6
5
|
|
6
|
+
CA_FILE_LOCK = Mutex.new unless defined?(CA_FILE_LOCK)
|
7
|
+
|
7
8
|
def initialize(env: ENV)
|
8
9
|
@config = {}
|
9
10
|
@config[:url] = env["REDIS_URL"] if env["REDIS_URL"]
|
@@ -15,10 +16,9 @@ class RedisEnvConfig
|
|
15
16
|
key = env["REDIS_KEY"] or raise Error, "missing environment variable REDIS_KEY"
|
16
17
|
x[:key] = OpenSSL::PKey::RSA.new(key)
|
17
18
|
x[:ca_file] = env["REDIS_CA_FILE"] or raise Error, "missing environment variable REDIS_CA_FILE"
|
18
|
-
|
19
|
-
File.open(x[:ca_file], "w") { |io| io.write(env["REDIS_CA"]) }
|
20
|
-
end
|
19
|
+
@ca = env["REDIS_CA"] if env["REDIS_CA"]
|
21
20
|
end
|
21
|
+
assure_redis_ca_file
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -26,4 +26,14 @@ class RedisEnvConfig
|
|
26
26
|
@config.dup
|
27
27
|
end
|
28
28
|
|
29
|
+
private
|
30
|
+
|
31
|
+
def assure_redis_ca_file
|
32
|
+
CA_FILE_LOCK.synchronize do
|
33
|
+
if @ca and !File.exist?(@config[:ssl_params][:ca_file])
|
34
|
+
File.open(@config[:ssl_params][:ca_file], "w") { |io| io.write(@ca) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
29
39
|
end
|