Skip to content

Commit

Permalink
Merge pull request #357 from hunner/hasInterfaceWithLookupBug
Browse files Browse the repository at this point in the history
(PUP-3597) Catch :undefined_variable when Future Parser is enabled on 3.7.x
  • Loading branch information
Morgan Haskel committed Nov 11, 2014
2 parents d8b86fd + 4949cfd commit 0a8963f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions lib/puppet/parser/functions/has_interface_with.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ module Puppet::Parser::Functions

kind, value = args

if lookupvar(kind) == value
# Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable
# https://tickets.puppetlabs.com/browse/PUP-3597
factval = nil
catch :undefined_variable do
factval = lookupvar(kind)
end
if factval == value
return true
end

Expand All @@ -44,7 +50,11 @@ module Puppet::Parser::Functions
iface.downcase!
factval = nil
begin
factval = lookupvar("#{kind}_#{iface}")
# Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable
# https://tickets.puppetlabs.com/browse/PUP-3597
catch :undefined_variable do
factval = lookupvar("#{kind}_#{iface}")
end
rescue Puppet::ParseError # Eat the exception if strict_variables = true is set
end
if value == factval
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/ensure_packages_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'

describe 'ensure_packages function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || fact('osfamily') == 'windows') do
describe 'ensure_packages function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) && fact('osfamily') != 'windows') do
describe 'success' do
it 'ensure_packages a package' do
apply_manifest('package { "rake": ensure => absent, provider => "gem", }')
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/ensure_resource_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'

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

0 comments on commit 0a8963f

Please sign in to comment.