Add cmd args for roles
This commit is contained in:
@@ -11,7 +11,8 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
*config.volume_args,
|
||||
*role.label_args,
|
||||
config.absolute_image,
|
||||
role.cmd
|
||||
role.cmd,
|
||||
*role.cmd_args
|
||||
end
|
||||
|
||||
def start
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Mrsk::Configuration::Role
|
||||
delegate :argumentize, :argumentize_env_with_secrets, to: Mrsk::Utils
|
||||
delegate :argumentize, :argumentize_env_with_secrets, :argumentize_for_cmd, to: Mrsk::Utils
|
||||
|
||||
attr_accessor :name
|
||||
|
||||
@@ -35,6 +35,14 @@ class Mrsk::Configuration::Role
|
||||
specializations["cmd"]
|
||||
end
|
||||
|
||||
def cmd_args
|
||||
if args = specializations["args"]
|
||||
argumentize_for_cmd args
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def running_traefik?
|
||||
name.web? || specializations["traefik"]
|
||||
end
|
||||
|
||||
@@ -34,6 +34,15 @@ class CommandsAppTest < ActiveSupport::TestCase
|
||||
@app.run.join(" ")
|
||||
end
|
||||
|
||||
test "run with cmd args" do
|
||||
@config[:servers] = { "web" => [ "1.1.1.1" ], "jobs" => { "hosts" => [ "1.1.1.2" ], "cmd" => "bin/jobs", "args" => { "mount" => "somewhere" } } }
|
||||
@app = Mrsk::Commands::App.new Mrsk::Configuration.new(@config).tap { |c| c.version = "999" }
|
||||
|
||||
assert_equal \
|
||||
"docker run --detach --restart unless-stopped --log-opt max-size=10m --name app-999 -e RAILS_MASTER_KEY=\"456\" --label service=\"app\" --label role=\"jobs\" dhh/app:999 bin/jobs --mount \"somewhere\"",
|
||||
@app.run(role: :jobs).join(" ")
|
||||
end
|
||||
|
||||
test "start" do
|
||||
assert_equal \
|
||||
"docker start app-999",
|
||||
|
||||
Reference in New Issue
Block a user