Skip to content

Commit

Permalink
Stop using legacy facts
Browse files Browse the repository at this point in the history
  • Loading branch information
tvpartytonight committed Feb 13, 2024
1 parent 9285277 commit a6cd5d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/provider/sshkey/parsed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def title
end

def self.default_target
case Facter.value(:operatingsystem)
case Facter.value('os.name')
when 'Darwin'
# Versions 10.11 and up use /etc/ssh/ssh_known_hosts
version = Facter.value(:macosx_productversion_major)
version = Facter.value('os.macos.version.major')
if version
if Puppet::Util::Package.versioncmp(version, '10.11') >= 0
'/etc/ssh/ssh_known_hosts'
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/provider/sshkey/parsed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ def key
context 'default ssh_known_hosts target path' do
['9.10', '9.11', '10.10'].each do |version|
it 'is `/etc/ssh_known_hosts` when OSX version 10.10 or older`' do
expect(Facter).to receive(:value).with(:operatingsystem).and_return('Darwin')
expect(Facter).to receive(:value).with(:macosx_productversion_major).and_return(version)
expect(Facter).to receive(:value).with('os.name').and_return('Darwin')
expect(Facter).to receive(:value).with('os.macos.version.major').and_return(version)
expect(subject.default_target).to eq('/etc/ssh_known_hosts')
end
end

['10.11', '10.13', '11.0', '11.11'].each do |version|
it 'is `/etc/ssh/ssh_known_hosts` when OSX version 10.11 or newer`' do
expect(Facter).to receive(:value).with(:operatingsystem).and_return('Darwin')
expect(Facter).to receive(:value).with(:macosx_productversion_major).and_return(version)
expect(Facter).to receive(:value).with('os.name').and_return('Darwin')
expect(Facter).to receive(:value).with('os.macos.version.major').and_return(version)
expect(subject.default_target).to eq('/etc/ssh/ssh_known_hosts')
end
end

it 'is `/etc/ssh/ssh_known_hosts` on other operating systems' do
expect(Facter).to receive(:value).with(:operatingsystem).and_return('RedHat')
expect(Facter).to receive(:value).with('os.name').and_return('RedHat')
expect(subject.default_target).to eq('/etc/ssh/ssh_known_hosts')
end
end
Expand Down

0 comments on commit a6cd5d0

Please sign in to comment.