Skip to content

Commit

Permalink
(CAT-2134) Removing legacy facts
Browse files Browse the repository at this point in the history
  • Loading branch information
amitkarsale committed Jan 16, 2025
1 parent 5e34dcb commit a2a872d
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ defaults: # Used for any hierarchy level that omits these keys.
data_hash: yaml_data # Use the built-in YAML backend.

hierarchy:
- name: "osfamily/major release"
- name: "os.family/major release"
paths:
# Used to distinguish between Debian and Ubuntu
- "os/%{facts.os.name}/%{facts.os.release.major}.yaml"
- "os/%{facts.os.family}/%{facts.os.release.major}.yaml"
# Used for Solaris
- "os/%{facts.os.family}/%{facts.kernelrelease}.yaml"
- name: "osfamily"
- name: "os.family"
paths:
- "os/%{facts.os.name}.yaml"
- "os/%{facts.os.family}.yaml"
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/apt_reboot_required.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# apt_reboot_required.rb
Facter.add(:apt_reboot_required) do
confine osfamily: 'Debian'
confine 'os.family': 'Debian'
setcode do
File.file?('/var/run/reboot-required')
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/apt_sources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This fact lists the .list filenames that are used by apt.
Facter.add(:apt_sources) do
confine osfamily: 'Debian'
confine 'os.family': 'Debian'
setcode do
sources = ['sources.list']
Dir.glob('/etc/apt/sources.list.d/*.{list,sources}').each do |file|
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/apt_update_last_success.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# This is generated upon a successful apt-get update run natively in ubuntu.
# the Puppetlabs-apt module deploys this same functionality for other debian-ish OSes
Facter.add('apt_update_last_success') do
confine osfamily: 'Debian'
confine 'os.family': 'Debian'
setcode do
if File.exist?('/var/lib/apt/periodic/update-success-stamp')
# get epoch time
Expand Down
4 changes: 2 additions & 2 deletions lib/facter/apt_updates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def get_updates(upgrade_option)
end

Facter.add('apt_has_updates') do
confine osfamily: 'Debian'
confine 'os.family': 'Debian'
setcode do
apt_package_updates = get_updates('upgrade')
apt_package_updates != [[], []] if !apt_package_updates.nil? && apt_package_updates.length == 2
end
end

Facter.add('apt_has_dist_updates') do
confine osfamily: 'Debian'
confine 'os.family': 'Debian'
setcode do
apt_dist_updates = get_updates('dist-upgrade')
apt_dist_updates != [[], []] if !apt_dist_updates.nil? && apt_dist_updates.length == 2
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/apt_key/apt_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
Puppet::Type.type(:apt_key).provide(:apt_key) do
desc 'apt-key provider for apt_key resource'

confine osfamily: :debian
defaultfor osfamily: :debian
confine 'os.family': :debian
defaultfor 'os.family': :debian
commands apt_key: 'apt-key'
commands gpg: '/usr/bin/gpg'

Expand Down
6 changes: 3 additions & 3 deletions spec/unit/facter/apt_dist_has_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

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

it { is_expected.to be_nil }
end

describe 'on Debian based distro missing apt-get' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).once.and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(false)
end
Expand All @@ -27,7 +27,7 @@

describe 'on Debian based distro' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).once.and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/facter/apt_dist_package_security_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

describe 'when apt has updates' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/facter/apt_dist_package_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

describe 'when apt has updates' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/facter/apt_dist_security_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

describe 'when apt has security updates' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/facter/apt_dist_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

describe 'when apt has updates' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/facter/apt_has_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

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

it { is_expected.to be_nil }
end

describe 'on Debian based distro missing apt-get' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).once.and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(false)
end
Expand All @@ -27,7 +27,7 @@

describe 'on Debian based distro' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/facter/apt_package_security_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

describe 'when apt has updates' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/facter/apt_package_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

describe 'when apt has updates' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/facter/apt_reboot_required_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

describe 'if a reboot is required' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:file?).and_return(true)
allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(true)
end
Expand All @@ -19,7 +19,7 @@

describe 'if a reboot is not required' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:file?).and_return(true)
allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(false)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/facter/apt_security_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

describe 'when apt has security updates' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/facter/apt_update_last_success_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

describe 'on Debian based distro which has not yet created the update-success-stamp file' do
it 'has a value of -1' do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:exist?).with('/var/lib/apt/periodic/update-success-stamp').and_return(false)
expect(subject).to eq(-1)
end
end

describe 'on Debian based distro which has created the update-success-stamp' do
it 'has the value of the mtime of the file' do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:exist?).and_return(true)
allow(File).to receive(:mtime).and_return(1_407_660_561)
expect(subject).to eq(1_407_660_561)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/facter/apt_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

describe 'when apt has updates' do
before(:each) do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(Facter.fact(:'os.family')).to receive(:value).and_return('Debian')
allow(File).to receive(:executable?) # Stub all other calls
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
Expand Down

0 comments on commit a2a872d

Please sign in to comment.