From 6aa7f2db9953d81afb75a3591358ba9e0dbc6935 Mon Sep 17 00:00:00 2001 From: Jesse Lovelace Date: Thu, 15 Oct 2015 11:25:57 -0500 Subject: Add check to ensure regex does not throw for none type. Add a quick check to ensure puppetversion value is not nil and supporting test. --- lib/facter/pe_version.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/facter/pe_version.rb b/lib/facter/pe_version.rb index 0cc0f64..c9f2181 100644 --- a/lib/facter/pe_version.rb +++ b/lib/facter/pe_version.rb @@ -10,8 +10,13 @@ # Facter.add("pe_version") do setcode do - pe_ver = Facter.value("puppetversion").match(/Puppet Enterprise (\d+\.\d+\.\d+)/) - pe_ver[1] if pe_ver + puppet_ver = Facter.value("puppetversion") + if puppet_ver != nil + pe_ver = puppet_ver.match(/Puppet Enterprise (\d+\.\d+\.\d+)/) + pe_ver[1] if pe_ver + else + nil + end end end -- cgit v1.2.3