Class: Kamal::Secrets
- Inherits:
-
Object
- Object
- Kamal::Secrets
- Defined in:
- lib/kamal/secrets.rb
Defined Under Namespace
Modules: Adapters
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(destination: nil) ⇒ Secrets
constructor
A new instance of Secrets.
- #secrets_files ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(destination: nil) ⇒ Secrets
Returns a new instance of Secrets.
6 7 8 9 |
# File 'lib/kamal/secrets.rb', line 6 def initialize(destination: nil) @destination = destination @mutex = Mutex.new end |
Instance Method Details
#[](key) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kamal/secrets.rb', line 11 def [](key) # Fetching secrets may ask the user for input, so ensure only one thread does that @mutex.synchronize do secrets.fetch(key) end rescue KeyError if secrets_files.present? raise Kamal::ConfigurationError, "Secret '#{key}' not found in #{secrets_files.join(", ")}" else raise Kamal::ConfigurationError, "Secret '#{key}' not found, no secret files (#{secrets_filenames.join(", ")}) provided" end end |
#secrets_files ⇒ Object
28 29 30 |
# File 'lib/kamal/secrets.rb', line 28 def secrets_files @secrets_files ||= secrets_filenames.select { |f| File.exist?(f) } end |
#to_h ⇒ Object
24 25 26 |
# File 'lib/kamal/secrets.rb', line 24 def to_h secrets end |