Skip to content

Commit 0a8963f

Browse files
author
Morgan Haskel
committed
Merge pull request #357 from hunner/hasInterfaceWithLookupBug
(PUP-3597) Catch :undefined_variable when Future Parser is enabled on 3.7.x
2 parents d8b86fd + 4949cfd commit 0a8963f

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/puppet/parser/functions/has_interface_with.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ module Puppet::Parser::Functions
3535

3636
kind, value = args
3737

38-
if lookupvar(kind) == value
38+
# Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable
39+
# https://tickets.puppetlabs.com/browse/PUP-3597
40+
factval = nil
41+
catch :undefined_variable do
42+
factval = lookupvar(kind)
43+
end
44+
if factval == value
3945
return true
4046
end
4147

@@ -44,7 +50,11 @@ module Puppet::Parser::Functions
4450
iface.downcase!
4551
factval = nil
4652
begin
47-
factval = lookupvar("#{kind}_#{iface}")
53+
# Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable
54+
# https://tickets.puppetlabs.com/browse/PUP-3597
55+
catch :undefined_variable do
56+
factval = lookupvar("#{kind}_#{iface}")
57+
end
4858
rescue Puppet::ParseError # Eat the exception if strict_variables = true is set
4959
end
5060
if value == factval

spec/acceptance/ensure_packages_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper_acceptance'
33

4-
describe 'ensure_packages function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || fact('osfamily') == 'windows') do
4+
describe 'ensure_packages function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) && fact('osfamily') != 'windows') do
55
describe 'success' do
66
it 'ensure_packages a package' do
77
apply_manifest('package { "rake": ensure => absent, provider => "gem", }')

spec/acceptance/ensure_resource_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper_acceptance'
33

4-
describe 'ensure_resource function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || fact('osfamily') == 'windows') do
4+
describe 'ensure_resource function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) && fact('osfamily') != 'windows') do
55
describe 'success' do
66
it 'ensure_resource a package' do
77
apply_manifest('package { "rake": ensure => absent, provider => "gem", }')

0 commit comments

Comments
 (0)