Sha256: 01534f6743caf470e729f3acb99293b9f82412aa3792a61f7d04040b765121d6
Contents?: true
Size: 1.01 KB
Versions: 22
Compression:
Stored size: 1.01 KB
Contents
class Kamal::Secrets::Dotenv::InlineCommandSubstitution class << self def install! ::Dotenv::Parser.substitutions.map! { |sub| sub == ::Dotenv::Substitutions::Command ? self : sub } end def call(value, _env, overwrite: false) # Process interpolated shell commands value.gsub(Dotenv::Substitutions::Command.singleton_class::INTERPOLATED_SHELL_COMMAND) do |*| # Eliminate opening and closing parentheses command = $LAST_MATCH_INFO[:cmd][1..-2] if $LAST_MATCH_INFO[:backslash] # Command is escaped, don't replace it. $LAST_MATCH_INFO[0][1..] else if command =~ /\A\s*kamal\s*secrets\s+/ # Inline the command inline_secrets_command(command) else # Execute the command and return the value `#{command}`.chomp end end end end def inline_secrets_command(command) Kamal::Cli::Main.start(command.shellsplit[1..] + [ "--inline" ]).chomp end end end
Version data entries
22 entries across 22 versions & 2 rubygems