From fa5f8af143ec478b321e4d2369fb10c9443ba38a Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Mon, 13 Apr 2026 19:26:59 +0000 Subject: [PATCH] Remove deprecated Facter::Core::Execution.exec and Resolution compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove `Facter::Core::Execution.exec`, which was deprecated in favor of `Facter::Core::Execution.execute` (#88). Remove the deprecated class-level `exec`/`which` compatibility exposure from `Facter::Util::Resolution` that bridged to `Facter::Core::Execution` since Facter 2.0.0 (#89). These two removals are coupled — `exec` on `Resolution` delegated through `Execution.exec`, so they must ship together. Update the acceptance test that called `Facter::Util::Resolution.exec` to use `Facter::Core::Execution.execute(cmd, on_fail: nil)` directly. Closes #88 #89 Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: Steven Pritchard --- .../execution_execute_sets_status_env_variable.rb | 2 +- lib/facter/custom_facts/core/execution.rb | 13 ------------- lib/facter/custom_facts/util/resolution.rb | 9 --------- spec/custom_facts/core/execution_spec.rb | 5 ----- 4 files changed, 1 insertion(+), 28 deletions(-) diff --git a/acceptance/tests/custom_facts/execution_execute_sets_status_env_variable.rb b/acceptance/tests/custom_facts/execution_execute_sets_status_env_variable.rb index c89c5d58c..271589252 100644 --- a/acceptance/tests/custom_facts/execution_execute_sets_status_env_variable.rb +++ b/acceptance/tests/custom_facts/execution_execute_sets_status_env_variable.rb @@ -13,7 +13,7 @@ content = <<-EOM Facter.add(:foo) do setcode do - Facter::Util::Resolution.exec("#{command}") + Facter::Core::Execution.execute("#{command}", on_fail: nil) "#{command} exited with code: %{status}" % {status: $?.exitstatus} end end diff --git a/lib/facter/custom_facts/core/execution.rb b/lib/facter/custom_facts/core/execution.rb index 9c61b460c..4dfb9c993 100644 --- a/lib/facter/custom_facts/core/execution.rb +++ b/lib/facter/custom_facts/core/execution.rb @@ -87,19 +87,6 @@ def with_env(values, &block) @@impl.with_env(values, &block) end - # Try to execute a command and return the output. - # - # @param command [String] Command to run - # - # @return [String/nil] Output of the program, or nil if the command does - # not exist or could not be executed. - # - # @deprecated Use #{execute} instead - # @api public - def exec(command) - @@impl.execute(command, on_fail: nil) - end - # Execute a command and return the output of that program. # # @param command [String] Command to run diff --git a/lib/facter/custom_facts/util/resolution.rb b/lib/facter/custom_facts/util/resolution.rb index dfb410ca7..fac161224 100644 --- a/lib/facter/custom_facts/util/resolution.rb +++ b/lib/facter/custom_facts/util/resolution.rb @@ -23,15 +23,6 @@ class Resolution extend Facter::Core::Execution class << self - # Expose command execution methods that were extracted into - # Facter::Core::Execution from Facter::Util::Resolution in Facter 2.0.0 for - # compatibility. - # - # @deprecated - # - # @api public - public :which, :exec - # @api private public :with_env end diff --git a/spec/custom_facts/core/execution_spec.rb b/spec/custom_facts/core/execution_spec.rb index 4f18df89d..66ad1117f 100644 --- a/spec/custom_facts/core/execution_spec.rb +++ b/spec/custom_facts/core/execution_spec.rb @@ -36,11 +36,6 @@ execution.expand_command('waffles') end - it 'delegates #exec to #execute' do - expect(impl).to receive(:execute).with('waffles', { on_fail: nil }) - execution.exec('waffles') - end - it 'delegates #execute to the implementation' do expect(impl).to receive(:execute).with('waffles', {}) execution.execute('waffles')