Allow custom options per role

This commit is contained in:
David Heinemeier Hansson
2023-03-09 11:09:19 +01:00
parent 98a14f6173
commit d3f07d6313
5 changed files with 15 additions and 15 deletions

View File

@@ -10,9 +10,9 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
*role.env_args,
*config.volume_args,
*role.label_args,
*role.option_args,
config.absolute_image,
role.cmd,
*role.cmd_args
role.cmd
end
def start

View File

@@ -1,5 +1,5 @@
class Mrsk::Commands::Traefik < Mrsk::Commands::Base
delegate :argumentize_for_cmd, to: Mrsk::Utils
delegate :optionize, to: Mrsk::Utils
CONTAINER_PORT = 80
@@ -13,7 +13,7 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
"traefik",
"--providers.docker",
"--log.level=DEBUG",
*cmd_args
*cmd_option_args
end
def start
@@ -54,9 +54,9 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
end
private
def cmd_args
def cmd_option_args
if args = config.raw_config.dig(:traefik, "args")
argumentize_for_cmd args
optionize args
else
[]
end

View File

@@ -1,5 +1,5 @@
class Mrsk::Configuration::Role
delegate :argumentize, :argumentize_env_with_secrets, :argumentize_for_cmd, to: Mrsk::Utils
delegate :argumentize, :argumentize_env_with_secrets, :optionize, to: Mrsk::Utils
attr_accessor :name
@@ -35,9 +35,9 @@ class Mrsk::Configuration::Role
specializations["cmd"]
end
def cmd_args
if args = specializations["args"]
argumentize_for_cmd args
def option_args
if args = specializations["options"]
optionize args
else
[]
end

View File

@@ -23,8 +23,8 @@ module Mrsk::Utils
end
end
# Returns a list of shell-dashed arguments to be used to start a command.
def argumentize_for_cmd(args)
# Returns a list of shell-dashed option arguments.
def optionize(args)
args.collect { |(key, value)| [ "--#{key}", escape_shell_value(value) ] }.flatten
end