Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(CONT-173) - Updating deprecated facter instances #534

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/facter/haproxy_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# Notes:
# None
# workaround Ubuntu 12.04: https://tickets.puppetlabs.com/browse/MODULES-2881
if defined?(Facter::Util::Resolution.which) && Facter::Util::Resolution.which('haproxy')
if defined?(Facter::Core::Execution.which) && Facter::Core::Execution.which('haproxy')
Facter.add('haproxy_version') do
haproxy_version_cmd = 'haproxy -v 2>&1'
haproxy_version_result = Facter::Util::Resolution.exec(haproxy_version_cmd)
haproxy_version_result = Facter::Core::Execution.execute(haproxy_version_cmd)
setcode do
haproxy_version_result.to_s.lines.first.strip.split(%r{HA?.Proxy})[1].strip.split(%r{version})[1].strip.split(%r{((\d+\.){2,}\d+).*})[1]
end
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/facter/haproxy_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
Copyright 2000-2014 Willy Tarreau <w@1wt.eu>
PUPPETCODE
it do
expect(Facter::Util::Resolution).to receive(:which).at_least(1).with('haproxy').and_return(true)
expect(Facter::Util::Resolution).to receive(:exec).at_least(1).with('haproxy -v 2>&1').and_return(haproxy_version_output)
expect(Facter::Core::Execution).to receive(:which).at_least(1).with('haproxy').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).at_least(1).with('haproxy -v 2>&1').and_return(haproxy_version_output)
expect(Facter.fact(:haproxy_version).value).to eq '1.5.3'
end
end

context 'when haproxy is not present' do
it do
allow(Facter::Util::Resolution).to receive(:exec)
expect(Facter::Util::Resolution).to receive(:which).at_least(1).with('haproxy').and_return(false)
allow(Facter::Core::Execution).to receive(:execute)
expect(Facter::Core::Execution).to receive(:which).at_least(1).with('haproxy').and_return(false)
expect(Facter.fact(:haproxy_version)).to be_nil
end
end
Expand Down