Class: Kamal::Configuration::Env
- Inherits:
-
Object
- Object
- Kamal::Configuration::Env
- Includes:
- Validation
- Defined in:
- lib/kamal/configuration/env.rb
Defined Under Namespace
Classes: Tag
Instance Attribute Summary collapse
-
#clear ⇒ Object
readonly
Returns the value of attribute clear.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#secrets_file ⇒ Object
readonly
Returns the value of attribute secrets_file.
-
#secrets_keys ⇒ Object
readonly
Returns the value of attribute secrets_keys.
Instance Method Summary collapse
- #args ⇒ Object
-
#initialize(config:, secrets_file: nil, context: "env") ⇒ Env
constructor
A new instance of Env.
- #merge(other) ⇒ Object
- #secrets ⇒ Object
- #secrets_directory ⇒ Object
- #secrets_io ⇒ Object
Methods included from Validation
Constructor Details
#initialize(config:, secrets_file: nil, context: "env") ⇒ Env
Returns a new instance of Env.
7 8 9 10 11 12 13 |
# File 'lib/kamal/configuration/env.rb', line 7 def initialize(config:, secrets_file: nil, context: "env") @clear = config.fetch("clear", config.key?("secret") || config.key?("tags") ? {} : config) @secrets_keys = config.fetch("secret", []) @secrets_file = secrets_file @context = context validate! config, context: context, with: Kamal::Configuration::Validator::Env end |
Instance Attribute Details
#clear ⇒ Object (readonly)
Returns the value of attribute clear.
4 5 6 |
# File 'lib/kamal/configuration/env.rb', line 4 def clear @clear end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/kamal/configuration/env.rb', line 4 def context @context end |
#secrets_file ⇒ Object (readonly)
Returns the value of attribute secrets_file.
4 5 6 |
# File 'lib/kamal/configuration/env.rb', line 4 def secrets_file @secrets_file end |
#secrets_keys ⇒ Object (readonly)
Returns the value of attribute secrets_keys.
4 5 6 |
# File 'lib/kamal/configuration/env.rb', line 4 def secrets_keys @secrets_keys end |
Instance Method Details
#args ⇒ Object
15 16 17 |
# File 'lib/kamal/configuration/env.rb', line 15 def args [ "--env-file", secrets_file, *argumentize("--env", clear) ] end |
#merge(other) ⇒ Object
31 32 33 34 35 |
# File 'lib/kamal/configuration/env.rb', line 31 def merge(other) self.class.new \ config: { "clear" => clear.merge(other.clear), "secret" => secrets_keys | other.secrets_keys }, secrets_file: secrets_file || other.secrets_file end |
#secrets ⇒ Object
23 24 25 |
# File 'lib/kamal/configuration/env.rb', line 23 def secrets @secrets ||= secrets_keys.to_h { |key| [ key, ENV.fetch(key) ] } end |
#secrets_directory ⇒ Object
27 28 29 |
# File 'lib/kamal/configuration/env.rb', line 27 def secrets_directory File.dirname(secrets_file) end |
#secrets_io ⇒ Object
19 20 21 |
# File 'lib/kamal/configuration/env.rb', line 19 def secrets_io StringIO.new(Kamal::EnvFile.new(secrets).to_s) end |