Class: Kamal::Configuration::Env

Inherits:
Object
  • Object
show all
Includes:
Validation
Defined in:
lib/kamal/configuration/env.rb

Defined Under Namespace

Classes: Tag

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validation

#validate!, #validation_yml

Constructor Details

#initialize(config:, secrets:, context: "env") ⇒ Env

Returns a new instance of Env.



8
9
10
11
12
13
14
# File 'lib/kamal/configuration/env.rb', line 8

def initialize(config:, secrets:, context: "env")
  @clear = config.fetch("clear", config.key?("secret") || config.key?("tags") ? {} : config)
  @secrets = secrets
  @secret_keys = config.fetch("secret", [])
  @context = context
  validate! config, context: context, with: Kamal::Configuration::Validator::Env
end

Instance Attribute Details

#clearObject (readonly)

Returns the value of attribute clear.



5
6
7
# File 'lib/kamal/configuration/env.rb', line 5

def clear
  @clear
end

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/kamal/configuration/env.rb', line 4

def context
  @context
end

#secret_keysObject (readonly)

Returns the value of attribute secret_keys.



5
6
7
# File 'lib/kamal/configuration/env.rb', line 5

def secret_keys
  @secret_keys
end

#secretsObject (readonly)

Returns the value of attribute secrets.



4
5
6
# File 'lib/kamal/configuration/env.rb', line 4

def secrets
  @secrets
end

Instance Method Details

#clear_argsObject



16
17
18
# File 'lib/kamal/configuration/env.rb', line 16

def clear_args
  argumentize("--env", clear)
end

#merge(other) ⇒ Object



24
25
26
27
28
# File 'lib/kamal/configuration/env.rb', line 24

def merge(other)
  self.class.new \
    config: { "clear" => clear.merge(other.clear), "secret" => secret_keys | other.secret_keys },
    secrets: secrets
end

#secrets_ioObject



20
21
22
# File 'lib/kamal/configuration/env.rb', line 20

def secrets_io
  Kamal::EnvFile.new(secret_keys.to_h { |key| [ key, secrets[key] ] }).to_io
end