[Pkg-puppet-devel] [facter] 318/352: (maint) Return nil on dns command lookup fail
Stig Sandbeck Mathisen
ssm at debian.org
Sun Apr 6 22:21:57 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit 129242762fbab469a1da5d60cbb602337776bdb9
Author: Adrien Thebo <git at somethingsinistral.net>
Date: Mon Mar 10 12:35:43 2014 -0700
(maint) Return nil on dns command lookup fail
This updates the domain fact to ignore the output of nonexistent
commands, rather than raising an error. While it would be better to
refactor the domain fact into smaller resolutions that can be confined
based on the presence of the command that's a more ambitious refactor
than what I can do right now.
---
lib/facter/domain.rb | 4 ++--
spec/unit/domain_spec.rb | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/facter/domain.rb b/lib/facter/domain.rb
index ac9aa68..3c2dc4c 100644
--- a/lib/facter/domain.rb
+++ b/lib/facter/domain.rb
@@ -41,11 +41,11 @@ Facter.add(:domain) do
basic_hostname
end
- if name = Facter::Core::Execution.exec(hostname_command) \
+ if name = Facter::Core::Execution.exec(hostname_command, :on_fail => nil) \
and name =~ /.*?\.(.+$)/
return_value = $1
- elsif Facter.value(:kernel) != "windows" and domain = Facter::Core::Execution.exec('dnsdomainname 2> /dev/null') \
+ elsif Facter.value(:kernel) != "windows" and domain = Facter::Core::Execution.exec('dnsdomainname 2> /dev/null', :on_fail => nil) \
and domain =~ /.+/
return_value = domain
diff --git a/spec/unit/domain_spec.rb b/spec/unit/domain_spec.rb
index c3701d5..f7dae51 100755
--- a/spec/unit/domain_spec.rb
+++ b/spec/unit/domain_spec.rb
@@ -24,11 +24,11 @@ describe "Domain name facts" do
let(:dnsdomain_command) { "dnsdomainname 2> /dev/null" }
def the_hostname_is(value)
- Facter::Core::Execution.stubs(:exec).with(hostname_command).returns(value)
+ Facter::Core::Execution.stubs(:exec).with(hostname_command, {:on_fail => nil}).returns(value)
end
def the_dnsdomainname_is(value)
- Facter::Core::Execution.stubs(:exec).with(dnsdomain_command).returns(value)
+ Facter::Core::Execution.stubs(:exec).with(dnsdomain_command, {:on_fail => nil}).returns(value)
end
before do
@@ -197,7 +197,7 @@ describe "Domain name facts" do
it "should return nil" do
expects_dnsdomains([nil])
- Facter::Core::Execution.stubs(:exec).with(hostname_command).returns('sometest')
+ Facter::Core::Execution.stubs(:exec).with(hostname_command, {:on_fail => nil}).returns('sometest')
FileTest.stubs(:exists?).with("/etc/resolv.conf").returns(false)
Facter.fact(:domain).value.should be_nil
@@ -288,8 +288,8 @@ describe "Domain name facts" do
describe scenario[:scenario] do
before(:each) do
- Facter::Core::Execution.stubs(:exec).with("hostname -f 2> /dev/null").returns(scenario[:hostname])
- Facter::Core::Execution.stubs(:exec).with("dnsdomainname 2> /dev/null").returns(scenario[:dnsdomainname])
+ Facter::Core::Execution.stubs(:exec).with("hostname -f 2> /dev/null", {:on_fail => nil}).returns(scenario[:hostname])
+ Facter::Core::Execution.stubs(:exec).with("dnsdomainname 2> /dev/null", {:on_fail => nil}).returns(scenario[:dnsdomainname])
resolv_conf_contains(
"search #{scenario[:resolve_search]}",
"domain #{scenario[:resolve_domain]}"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list