summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Cooper <josh+github@puppetlabs.com>2014-10-10 09:14:59 -0700
committerJosh Cooper <josh+github@puppetlabs.com>2014-10-10 09:14:59 -0700
commit0875a94ff7aa6faaee95e66088348825a15810a3 (patch)
treeb905593d0d4acf31a73211b417c5992a19412121
parent9f4f7e1af873b8e7ce1404c5cd4c4fdd1f33a07a (diff)
parentaae6e938485e4d3be6b0130153940b2a4f3d6e06 (diff)
downloadpuppet-0875a94ff7aa6faaee95e66088348825a15810a3.tar.gz
Merge pull request #3177 from kylog/issue/stable/pup-643/pkg-skip-certificate-expiration-warnings
Issue/stable/pup 643/pkg skip certificate expiration warnings
-rw-r--r--lib/puppet/provider/package/pkg.rb13
-rw-r--r--spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning2
-rwxr-xr-xspec/unit/provider/package/pkg_spec.rb4
3 files changed, 18 insertions, 1 deletions
diff --git a/lib/puppet/provider/package/pkg.rb b/lib/puppet/provider/package/pkg.rb
index 4192dca85..db7c0a008 100644
--- a/lib/puppet/provider/package/pkg.rb
+++ b/lib/puppet/provider/package/pkg.rb
@@ -126,7 +126,18 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d
# http://defect.opensolaris.org/bz/show_bug.cgi?id=19159%
# notes that we can't use -Ha for the same even though the manual page reads that way.
def latest
- lst = pkg(:list, "-Hn", @resource[:name]).split("\n").map{|l|self.class.parse_line(l)}
+ lines = pkg(:list, "-Hn", @resource[:name]).split("\n")
+
+ # remove certificate expiration warnings from the output, but report them
+ # Note: we'd like to use select! here to modify the lines array and avoid
+ # the second select further down. But Solaris 11 comes with ruby 1.8.7
+ # which doesn't support select!, so do this as two selects.
+ cert_warnings = lines.select { |line| line =~ /^Certificate/ }
+ if cert_warnings
+ Puppet.warning("pkg warning: #{cert_warnings}")
+ end
+
+ lst = lines.select { |line| line !~ /^Certificate/ }.map { |line| self.class.parse_line(line) }
# Now we know there is a newer version. But is that installable? (i.e are there any constraints?)
# return the first known we find. The only way that is currently available is to do a dry run of
diff --git a/spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning b/spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning
new file mode 100644
index 000000000..83849be03
--- /dev/null
+++ b/spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning
@@ -0,0 +1,2 @@
+Certificate '/var/pkg/ssl/871b4ed0ade09926e6adf95f86bf17535f987684' for publisher 'solarisstudio', needed to access 'https://pkg.oracle.com/solarisstudio/release/', will expire in '29' days.
+dummy 1.0.6-0.175.0.0.0.2.537 i--
diff --git a/spec/unit/provider/package/pkg_spec.rb b/spec/unit/provider/package/pkg_spec.rb
index 8ddbbbfe0..9442b7f21 100755
--- a/spec/unit/provider/package/pkg_spec.rb
+++ b/spec/unit/provider/package/pkg_spec.rb
@@ -70,6 +70,10 @@ describe Puppet::Type.type(:package).provider(:pkg) do
described_class.expects(:pkg).with(:list,'-Hn','dummy').returns File.read(my_fixture('dummy_solaris11.installed'))
provider.latest.should == "1.0.6-0.175.0.0.0.2.537"
end
+ it "should work correctly for ensure latest on solaris 11 in the presence of a certificate expiration warning" do
+ described_class.expects(:pkg).with(:list,'-Hn','dummy').returns File.read(my_fixture('dummy_solaris11.certificate_warning'))
+ provider.latest.should == "1.0.6-0.175.0.0.0.2.537"
+ end
it "should work correctly for ensure latest on solaris 11(known UFOXI)" do
Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '-n', 'dummy'], {:failonfail => false, :combine => true}).returns ''
$CHILD_STATUS.stubs(:exitstatus).returns 0