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.



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

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.



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

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.



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

def secret_keys
  @secret_keys
end

Instance Method Details

#clear_argsObject



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

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

#merge(other) ⇒ Object



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

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

#secrets_ioObject



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

def secrets_io
  Kamal::EnvFile.new(aliased_secrets).to_io
end