From 739dd06c9c90ce00d1bc7f6dea91aa1723da40d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 18 Jul 2021 22:36:58 +0200 Subject: Pacman hook paths shouldn't start with '/'. --- modules/pacman/manifests/hook.pp | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'modules/pacman/manifests/hook.pp') diff --git a/modules/pacman/manifests/hook.pp b/modules/pacman/manifests/hook.pp index 940ae5f..f8478e6 100644 --- a/modules/pacman/manifests/hook.pp +++ b/modules/pacman/manifests/hook.pp @@ -25,9 +25,33 @@ define pacman::hook ( fail('abortOnFail only valid when "when" => "PreTransation"') } - $triggers = $trigger ? { + # Normalize triggers to list + $triggers = ($trigger ? { Array => $trigger, default => [$trigger], + }).map |$trigger| { + # Normalize contents of each trigger, making + { + type => $trigger['type'], + operation => $trigger['operation'] ? { + Array => $trigger['operation'], + default => [$trigger['operation']], + }, + target => $trigger['target'] ? { + Array => $trigger['target'], + default => [$trigger['target']], + } + } + } + + $triggers.each |$trigger| { + if $trigger['type'] == 'Path' { + $trigger['target'].each |$target| { + if $target[0] == '/' { + fail("Target paths shouldn't start with '/' ${target} in trigger ${name}") + } + } + } } $str = epp('pacman/hook.epp', { @@ -37,19 +61,7 @@ define pacman::hook ( Array => $depends, default => [$depends], }, - triggers => $triggers.map |$trigger| { - { - type => $trigger['type'], - operation => $trigger['operation'] ? { - Array => $trigger['operation'], - default => [$trigger['operation']], - }, - target => $trigger['target'] ? { - Array => $trigger['target'], - default => [$trigger['target']], - } - } - }, + triggers => $triggers, exec => $exec, when => $when, abortOnFail => $abortOnFail, -- cgit v1.2.3