From 72598df7c3ed57afd0047bae1da808bfc6e885b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 15 Jan 2023 12:35:28 +0100 Subject: Fail properly for failed filter type inferrence. --- manifests/filter.pp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/manifests/filter.pp b/manifests/filter.pp index 76bdcd3..241bd62 100644 --- a/manifests/filter.pp +++ b/manifests/filter.pp @@ -14,9 +14,13 @@ define cgit::filter ( Optional[Variant[String, Array[String]]] $source = undef, Optional[String] $content = undef, Hash $file_props = {}, - Enum['lua', 'exec'] $type = stdlib::extname($source) ? { - '.lua' => 'lua', - default => 'exec', + Enum['lua', 'exec'] $type = $source ? { + Undef => fail("Type must be explictly set when source isn't used."), + Array => fail("Type can't be inferred from arrays."), + String => stdlib::extname($source) ? { + '.lua' => 'lua', + default => 'exec', + }, } ) { include cgit::filter_setup -- cgit v1.2.3