From 1deae36b06b8e31ed7e8c3c7cfa51c6d04981600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 9 Sep 2024 16:15:15 -1000 Subject: [PATCH 1/2] Only provide default values for required parameters The test suite already provide optional parameter values for each test that rely on them, so we do not need to pass them to all tests. Moreover, some on these changed default values prevent the test suite from failing because of a regression introduced when refactoring maps. Remove the default values to trigger the test suite breakage and allow checking that a fix is working as expected. --- spec/defines/resource_map_spec.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/defines/resource_map_spec.rb b/spec/defines/resource_map_spec.rb index 6cd03b2d2..14bf1e79f 100644 --- a/spec/defines/resource_map_spec.rb +++ b/spec/defines/resource_map_spec.rb @@ -15,12 +15,6 @@ let :default_params do { string: '$uri', - default: 'pool_a', - mappings: { - 'foo' => 'pool_b', - 'bar' => 'pool_c', - 'baz' => 'pool_d' - } } end From 04dd7217dc4d7aa9e855bcfcf72f45e027977898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 9 Sep 2024 16:21:24 -1000 Subject: [PATCH 2/2] Fix catalog compilation when no `mappings` are passed Only attempt to compute the longest key of mappings when mappings are actually passed. --- templates/conf.d/map.epp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/conf.d/map.epp b/templates/conf.d/map.epp index 612bc5eed..8cbb816c0 100644 --- a/templates/conf.d/map.epp +++ b/templates/conf.d/map.epp @@ -17,6 +17,7 @@ map <%= $string %> $<%= $name %> { <%- $include_files.each |$h| { -%> include <%= $h %>; <%- } -%> +<%- unless $mappings.empty { -%> <%- $m = $mappings ? { @@ -28,4 +29,5 @@ $field_width = $m.map |$x| { $x['key'].length }.max <%- $m.each |$h| { -%> <%= sprintf("%-*s %s", $field_width, $h['key'], $h['value']) %>; <%- } -%> +<%- } -%> }