Add configuration for hooks_path

This commit is contained in:
Donal McBreen
2023-05-22 11:09:13 +01:00
parent f3ec9f19c8
commit 910f14e9c0
4 changed files with 21 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
class Mrsk::Commands::Hook < Mrsk::Commands::Base
def run(hook, **details)
[ ".mrsk/hooks/#{hook}", env: tags(**details).env ]
[ hook_file(hook), env: tags(**details).env ]
end
def hook_exists?(hook)
@@ -9,6 +9,6 @@ class Mrsk::Commands::Hook < Mrsk::Commands::Base
private
def hook_file(hook)
".mrsk/hooks/#{hook}"
"#{config.hooks_path}/#{hook}"
end
end

View File

@@ -6,7 +6,7 @@ require "erb"
require "net/ssh/proxy/jump"
class Mrsk::Configuration
delegate :service, :image, :servers, :env, :labels, :registry, :builder, :stop_wait_time, to: :raw_config, allow_nil: true
delegate :service, :image, :servers, :env, :labels, :registry, :builder, :stop_wait_time, :hooks_path, to: :raw_config, allow_nil: true
delegate :argumentize, :argumentize_env_with_secrets, :optionize, to: Mrsk::Utils
attr_accessor :destination
@@ -197,6 +197,10 @@ class Mrsk::Configuration
raw_config.traefik || {}
end
def hooks_path
raw_config.hooks_path || ".mrsk/hooks"
end
private
# Will raise ArgumentError if any required config keys are missing
def ensure_required_keys_present