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

Replace legacy facts #344

Merged
merged 1 commit into from
Dec 12, 2024
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
2 changes: 1 addition & 1 deletion lib/facter/yum_reboot_required.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'English'

Facter.add(:yum_reboot_required) do
confine osfamily: 'RedHat'
confine 'os.family': 'RedHat'
setcode do
if File.exist?('/usr/bin/needs-restarting')
Facter::Core::Execution.execute('/usr/bin/needs-restarting --reboothint')
Expand Down
6 changes: 3 additions & 3 deletions lib/facter/yum_updates.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Facter.add('yum_package_updates') do
confine osfamily: 'RedHat'
confine 'os.family': 'RedHat'
setcode do
yum_updates = []

Expand All @@ -18,14 +18,14 @@
end

Facter.add('yum_has_updates') do
confine osfamily: 'RedHat'
confine 'os.family': 'RedHat'
setcode do
Facter.value(:yum_package_updates).any?
end
end

Facter.add('yum_updates') do
confine osfamily: 'RedHat'
confine 'os.family': 'RedHat'
setcode do
Facter.value(:yum_package_updates).length
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/facter/yum_package_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

describe 'on non-Redhat distro' do
before do
allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Debian')
allow(Facter.fact('os.family')).to receive(:value).and_return('Debian')
end

it { is_expected.to be_nil }
end

describe 'on Redhat distro' do
before do
allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Redhat')
allow(Facter.fact('os.family')).to receive(:value).and_return('Redhat')
allow(File).to receive(:executable?) # Stub all other calls
allow(File).to receive(:executable?).with('/usr/bin/yum').and_return(true)
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/yum --assumeyes --quiet --cacheonly list updates').and_return(yum_list_updates_result)
Expand Down
Loading