Sha256: 663d0e1b20a315653b8545d4c66628e9bf9fd4aaf92bd2a6b632b2c082127ab0

Contents?: true

Size: 1.02 KB

Versions: 12

Compression:

Stored size: 1.02 KB

Contents

class Kamal::Configuration::Env
  include Kamal::Configuration::Validation

  attr_reader :secrets_keys, :clear, :secrets_file, :context
  delegate :argumentize, to: Kamal::Utils

  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

  def args
    [ "--env-file", secrets_file, *argumentize("--env", clear) ]
  end

  def secrets_io
    StringIO.new(Kamal::EnvFile.new(secrets).to_s)
  end

  def secrets
    @secrets ||= secrets_keys.to_h { |key| [ key, ENV.fetch(key) ] }
  end

  def secrets_directory
    File.dirname(secrets_file)
  end

  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
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kamal-1.9.2 lib/kamal/configuration/env.rb
kamal-1.9.1 lib/kamal/configuration/env.rb
kamal-1.9.0 lib/kamal/configuration/env.rb
kamal-2.0.0.alpha lib/kamal/configuration/env.rb
kamal-1.8.3 lib/kamal/configuration/env.rb
kamal-1.8.2 lib/kamal/configuration/env.rb
kamal-1.8.1 lib/kamal/configuration/env.rb
kamal-1.8.0 lib/kamal/configuration/env.rb
kamal-1.7.3 lib/kamal/configuration/env.rb
kamal-1.7.2 lib/kamal/configuration/env.rb
kamal-1.7.1 lib/kamal/configuration/env.rb
kamal-1.7.0 lib/kamal/configuration/env.rb