Extract Kamal::EnvFile

Cleaning up the Utils junk drawer.
This commit is contained in:
dhh
2023-09-16 10:55:41 -07:00
parent 3a8eb0cf7d
commit 873be0b76b
7 changed files with 149 additions and 106 deletions

View File

@@ -92,13 +92,6 @@ module Kamal::Utils
.gsub(DOLLAR_SIGN_WITHOUT_SHELL_EXPANSION_REGEX, '\$')
end
# Escape a value to make it safe to dump in a docker file.
def escape_docker_env_file_value(value)
# Doublequotes are treated literally in docker env files
# so remove leading and trailing ones and unescape any others
value.to_s.dump[1..-2].gsub(/\\"/, "\"")
end
# Abbreviate a git revhash for concise display
def abbreviate_version(version)
if version
@@ -114,8 +107,4 @@ module Kamal::Utils
def uncommitted_changes
`git status --porcelain`.strip
end
def docker_env_file_line(key, value)
"#{key.to_s}=#{escape_docker_env_file_value(value)}\n"
end
end