Module: SamsonSecretPuller
- Extended by:
- Forwardable
- Defined in:
- lib/samson_secret_puller.rb
Constant Summary collapse
- FOLDER =
'/secrets'- ENV =
store a copy since we might replace ENV on Object
ENV
Class Method Summary collapse
- .[]=(key, value) ⇒ Object
- .delete(key) ⇒ Object
- .replace(other) ⇒ Object
-
.replace_ENV! ⇒ Object
When we run in kubernetes we need to read secrets from ENV and secret storage but other parts of the apps or gems do not need to know about this.
- .to_h ⇒ Object (also: to_hash, dup)
Class Method Details
.[]=(key, value) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/samson_secret_puller.rb', line 25 def []=(key, value) if value.nil? delete key elsif secrets && @secret_keys.include?(key) secrets[key] = value else ENV[key] = secrets[key] = value end end |
.delete(key) ⇒ Object
35 36 37 38 |
# File 'lib/samson_secret_puller.rb', line 35 def delete(key) secrets.delete(key) ENV.delete(key) end |
.replace(other) ⇒ Object
40 41 42 |
# File 'lib/samson_secret_puller.rb', line 40 def replace(other) (secrets.keys + other.keys).uniq.each { |k| self[k] = other[k] } end |
.replace_ENV! ⇒ Object
When we run in kubernetes we need to read secrets from ENV and secret storage but other parts of the apps or gems do not need to know about this
46 47 48 49 50 51 52 |
# File 'lib/samson_secret_puller.rb', line 46 def replace_ENV! # rubocop:disable Naming/MethodName old = $VERBOSE $VERBOSE = nil Object.const_set(:ENV, self) ensure $VERBOSE = old end |
.to_h ⇒ Object Also known as: to_hash, dup
19 20 21 |
# File 'lib/samson_secret_puller.rb', line 19 def to_h secrets.dup end |