Sha256: c460461519923f6950290d712ffb24ce25f8b6be2a53f4357d15cd6312fcfc23
Contents?: true
Size: 954 Bytes
Versions: 13
Compression:
Stored size: 954 Bytes
Contents
require "dotenv" class Kamal::Secrets attr_reader :secrets_files Kamal::Secrets::Dotenv::InlineCommandSubstitution.install! def initialize(destination: nil) @secrets_files = \ [ ".kamal/secrets-common", ".kamal/secrets#{(".#{destination}" if destination)}" ].select { |f| File.exist?(f) } @mutex = Mutex.new end def [](key) # Fetching secrets may ask the user for input, so ensure only one thread does that @mutex.synchronize do secrets.fetch(key) end rescue KeyError if secrets_files raise Kamal::ConfigurationError, "Secret '#{key}' not found in #{secrets_files.join(", ")}" else raise Kamal::ConfigurationError, "Secret '#{key}' not found, no secret files provided" end end def to_h secrets end private def secrets @secrets ||= secrets_files.inject({}) do |secrets, secrets_file| secrets.merge!(::Dotenv.parse(secrets_file)) end end end
Version data entries
13 entries across 13 versions & 1 rubygems