Skip to content

Commit 1c382e1

Browse files
authored
Merge pull request #1068 from puppetlabs/cont-173/main/updating_deprecated_facter
(CONT-173) - Updating deprecated facter instances
2 parents 40ec6fc + 1442e42 commit 1c382e1

12 files changed

+27
-27
lines changed

lib/facter/apt_updates.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def get_updates(upgrade_option)
1010
apt_updates = nil
1111
if File.executable?('/usr/bin/apt-get')
12-
apt_get_result = Facter::Util::Resolution.exec("/usr/bin/apt-get -s -o Debug::NoLocking=true #{upgrade_option} 2>&1")
12+
apt_get_result = Facter::Core::Execution.execute("/usr/bin/apt-get -s -o Debug::NoLocking=true #{upgrade_option} 2>&1")
1313
unless apt_get_result.nil?
1414
apt_updates = [[], []]
1515
apt_get_result.each_line do |line|

manifests/source.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
$sourcelist = epp('apt/source.list.epp', {
143143
'comment' => $comment,
144144
'includes' => $includes,
145-
'options' => delete_undef_values( {
145+
'options' => delete_undef_values({
146146
'arch' => $architecture,
147147
'trusted' => $allow_unsigned ? { true => 'yes', false => undef },
148148
'allow-insecure' => $allow_insecure ? { true => 'yes', false => undef },

spec/unit/facter/apt_dist_has_updates_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
before(:each) do
2828
allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Debian')
2929
allow(File).to receive(:executable?) # Stub all other calls
30-
allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls
30+
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
3131
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
32-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
32+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
3333
apt_output = "Inst extremetuxracer [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
3434
"Conf extremetuxracer (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
3535
"Inst planet.rb [13-1.1] (22-2~bpo8+1 Debian Backports:stretch-backports [all])\n" \
3636
"Conf planet.rb (22-2~bpo8+1 Debian Backports:stretch-backports [all])\n"
37-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output)
37+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output)
3838
end
3939
it { is_expected.to be true }
4040
end

spec/unit/facter/apt_dist_package_security_updates_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
before(:each) do
1919
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
2020
allow(File).to receive(:executable?) # Stub all other calls
21-
allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls
21+
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
2222
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
23-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
23+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
2424
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
25-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_get_upgrade_output)
25+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_get_upgrade_output)
2626
end
2727

2828
describe 'on Debian' do

spec/unit/facter/apt_dist_package_updates_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
before(:each) do
1919
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
2020
allow(File).to receive(:executable?) # Stub all other calls
21-
allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls
21+
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
2222
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
23-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
23+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
2424
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
2525
apt_output = "Inst extremetuxracer [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
2626
"Conf extremetuxracer (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
2727
"Inst planet.rb [13-1.1] (22-2~bpo8+1 Debian Backports:-backports [all])\n" \
2828
"Conf planet.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n"
29-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output)
29+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output)
3030
end
3131
it { is_expected.to eq(['extremetuxracer', 'planet.rb']) }
3232
end

spec/unit/facter/apt_dist_security_updates_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
before(:each) do
1919
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
2020
allow(File).to receive(:executable?) # Stub all other calls
21-
allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls
21+
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
2222
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
23-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
23+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
2424
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
25-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_get_upgrade_output)
25+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_get_upgrade_output)
2626
end
2727

2828
describe 'on Debian' do

spec/unit/facter/apt_dist_updates_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
before(:each) do
1919
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
2020
allow(File).to receive(:executable?) # Stub all other calls
21-
allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls
21+
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
2222
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
23-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
23+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
2424
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
2525
apt_output = "Inst extremetuxracer [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
2626
"Conf extremetuxracer (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
2727
"Inst planet.rb [13-1.1] (22-2~bpo8+1 Debian Backports:-backports [all])\n" \
2828
"Conf planet.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n"
29-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output)
29+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output)
3030
end
3131
it { is_expected.to eq(2) }
3232
end

spec/unit/facter/apt_has_updates_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
before(:each) do
2828
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
2929
allow(File).to receive(:executable?) # Stub all other calls
30-
allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls
30+
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
3131
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
3232
apt_output = "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
3333
"Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
3434
"Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:-backports [all])\n" \
3535
"Conf unhide.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n"
36-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output)
36+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output)
3737
end
3838
it { is_expected.to be true }
3939
end

spec/unit/facter/apt_package_security_updates_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
before(:each) do
1919
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
2020
allow(File).to receive(:executable?) # Stub all other calls
21-
allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls
21+
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
2222
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
23-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_get_upgrade_output)
23+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_get_upgrade_output)
2424
end
2525

2626
describe 'on Debian' do

spec/unit/facter/apt_package_updates_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
before(:each) do
1919
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
2020
allow(File).to receive(:executable?) # Stub all other calls
21-
allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls
21+
allow(Facter::Core::Execution).to receive(:execute) # Catch all other calls
2222
allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
2323
apt_output = "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
2424
"Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
2525
"Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:-backports [all])\n" \
2626
"Conf unhide.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n"
27-
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output)
27+
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output)
2828
end
2929
it { is_expected.to eq(['tzdata', 'unhide.rb']) }
3030
end

0 commit comments

Comments
 (0)