Class: Kamal::Dev::SecretsLoader
- Inherits:
-
Object
- Object
- Kamal::Dev::SecretsLoader
- Defined in:
- lib/kamal/dev/secrets_loader.rb
Overview
Loads and processes secrets from .kamal/secrets file
Parses shell script format (export KEY="value") and provides Base64-encoded values for container injection.
Defined Under Namespace
Classes: SecretsNotFoundError, SecretsParseError
Instance Attribute Summary collapse
-
#secrets_file ⇒ Object
readonly
Returns the value of attribute secrets_file.
Instance Method Summary collapse
-
#initialize(secrets_file_path = ".kamal/secrets") ⇒ SecretsLoader
constructor
Initialize secrets loader with file path.
-
#load_secrets ⇒ Hash<String, String>
Load and parse secrets from file.
-
#load_secrets_for(keys) ⇒ Hash<String, String>
Load secrets for specific keys only.
Constructor Details
#initialize(secrets_file_path = ".kamal/secrets") ⇒ SecretsLoader
Initialize secrets loader with file path
28 29 30 |
# File 'lib/kamal/dev/secrets_loader.rb', line 28 def initialize(secrets_file_path = ".kamal/secrets") @secrets_file = secrets_file_path end |
Instance Attribute Details
#secrets_file ⇒ Object (readonly)
Returns the value of attribute secrets_file.
23 24 25 |
# File 'lib/kamal/dev/secrets_loader.rb', line 23 def secrets_file @secrets_file end |
Instance Method Details
#load_secrets ⇒ Hash<String, String>
Load and parse secrets from file
37 38 39 40 41 42 43 |
# File 'lib/kamal/dev/secrets_loader.rb', line 37 def load_secrets unless File.exist?(@secrets_file) raise SecretsNotFoundError, "Secrets file not found: #{@secrets_file}" end parse_secrets_file end |
#load_secrets_for(keys) ⇒ Hash<String, String>
Load secrets for specific keys only
49 50 51 52 53 54 |
# File 'lib/kamal/dev/secrets_loader.rb', line 49 def load_secrets_for(keys) all_secrets = load_secrets keys.each_with_object({}) do |key, result| result[key] = all_secrets[key] if all_secrets.key?(key) end end |