From eedccc7a097135deacfc081385047d8476cb9854 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Fri, 5 Apr 2024 10:31:54 -0700 Subject: [PATCH] Revert "Merge pull request #2699 from mhashizume/FACT-3156/main/confine-lowercase" This reverts commit 06fa3066c3ddf7fe1bec2f4cf8f79e26fb1edb53, reversing changes made to 8b77e6f60665afc9d8378ad03772f8b670a8cafd. --- lib/facter/custom_facts/util/confine.rb | 6 ++---- spec/custom_facts/util/confine_spec.rb | 6 ------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/facter/custom_facts/util/confine.rb b/lib/facter/custom_facts/util/confine.rb index 4c2feec823..d4bd144efb 100644 --- a/lib/facter/custom_facts/util/confine.rb +++ b/lib/facter/custom_facts/util/confine.rb @@ -35,7 +35,7 @@ def to_s end # Evaluate the fact, returning true or false. - # if we have a block parameter then we only evaluate that instead + # if we have a block paramter then we only evaluate that instead def true? if @block && !@fact begin @@ -54,11 +54,9 @@ def true? return false if value.nil? - # We call the block with both the downcased and raw fact value for - # backwards-compatibility. if @block begin - return !@block.call(value).nil? || !@block.call(fact.value).nil? + return !!@block.call(value) rescue StandardError => e log.debug "Confine raised #{e.class} #{e}" return false diff --git a/spec/custom_facts/util/confine_spec.rb b/spec/custom_facts/util/confine_spec.rb index 3df539cf79..0b1bdf628e 100755 --- a/spec/custom_facts/util/confine_spec.rb +++ b/spec/custom_facts/util/confine_spec.rb @@ -126,12 +126,6 @@ def confined(fact_value, *confines) expect(confine.true?).to be true end - it 'accepts and evaluate a block argument against the fact while respecting case' do - allow(fact).to receive(:value).and_return 'Foo' - confine = LegacyFacter::Util::Confine.new(:yay) { |f| f == 'Foo' } - expect(confine.true?).to be true - end - it 'returns false if the block raises a StandardError when checking a fact' do allow(fact).to receive(:value).and_return 'foo' confine = LegacyFacter::Util::Confine.new(:yay) { |_f| raise StandardError }