From 5ad49ebaecbdbc6faa58282c45aad1c46d4d7f2c Mon Sep 17 00:00:00 2001 From: Alex Dacre Date: Wed, 26 Apr 2017 12:47:29 +0100 Subject: Fix issue where the following causes obscure catalog compilation errors: ``` file { '/tmp/somefile': ensure => 'file', } File['/tmp/somefile'] -> Package <| |> ensure_packages($somearray) ``` If $somearray is undefined or one of the elements contains an empty string, an error like the following is thrown: Could not find resource 'Package[]' for relationship from 'File[/tmp/somefile]' on node $::fqdn --- lib/puppet/parser/functions/ensure_packages.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/functions/ensure_packages.rb b/lib/puppet/parser/functions/ensure_packages.rb index 17942b8..034f997 100644 --- a/lib/puppet/parser/functions/ensure_packages.rb +++ b/lib/puppet/parser/functions/ensure_packages.rb @@ -36,6 +36,7 @@ third argument to the ensure_resource() function. Puppet::Parser::Functions.function(:ensure_resource) packages.each { |package_name| + raise(Puppet::ParseError, 'ensure_packages(): Empty String provided for package name') if package_name.length == 0 if !findresource("Package[#{package_name}]") function_ensure_resource(['package', package_name, defaults ]) end -- cgit v1.2.3