Properly pass traefik command options

Traefik command options need to be passed as `--key=value`, not `--key value`.
This commit is contained in:
Tobias Bühlmann
2023-03-14 15:04:33 +01:00
parent b668ce3f25
commit 3ca5bc50b6
3 changed files with 12 additions and 6 deletions

View File

@@ -56,7 +56,7 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
private
def cmd_option_args
if args = config.traefik["args"]
optionize args
optionize args, with: "="
else
[]
end

View File

@@ -24,8 +24,14 @@ module Mrsk::Utils
end
# Returns a list of shell-dashed option arguments. If the value is true, it's treated like a value-less option.
def optionize(args)
args.collect { |(key, value)| [ "--#{key}", value == true ? nil : escape_shell_value(value) ] }.flatten.compact
def optionize(args, with: nil)
options = if with
args.collect { |(key, value)| value == true ? "--#{key}" : "--#{key}#{with}#{escape_shell_value(value)}" }
else
args.collect { |(key, value)| [ "--#{key}", value == true ? nil : escape_shell_value(value) ] }
end
options.flatten.compact
end
# Copied from SSHKit::Backend::Abstract#redact to be available inside Commands classes