Allow arbitrary docker options for traefik
This commit is contained in:
@@ -25,15 +25,21 @@ module Mrsk::Utils
|
||||
|
||||
# Returns a list of shell-dashed option arguments. If the value is true, it's treated like a value-less option.
|
||||
def optionize(args, with: nil)
|
||||
flattened_args = flatten_args args
|
||||
options = if with
|
||||
args.collect { |(key, value)| value == true ? "--#{key}" : "--#{key}#{with}#{escape_shell_value(value)}" }
|
||||
flattened_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) ] }
|
||||
flattened_args.collect { |(key, value)| [ "--#{key}", value == true ? nil : escape_shell_value(value) ] }
|
||||
end
|
||||
|
||||
options.flatten.compact
|
||||
end
|
||||
|
||||
# Flattens a one-to-many structure into an array of two-element arrays each containing a key-value pair
|
||||
def flatten_args(args)
|
||||
args.flat_map { |key, value| value.respond_to?('map') ? value.map { |entry| [key, entry] }: [[key, value]] }
|
||||
end
|
||||
|
||||
# Copied from SSHKit::Backend::Abstract#redact to be available inside Commands classes
|
||||
def redact(arg) # Used in execute_command to hide redact() args a user passes in
|
||||
arg.to_s.extend(SSHKit::Redaction) # to_s due to our inability to extend Integer, etc
|
||||
|
||||
Reference in New Issue
Block a user