diff options
author | Kylo Ginsberg <kylo@puppetlabs.com> | 2014-10-09 23:04:30 -0700 |
---|---|---|
committer | Kylo Ginsberg <kylo@puppetlabs.com> | 2014-10-10 00:15:06 -0700 |
commit | aae6e938485e4d3be6b0130153940b2a4f3d6e06 (patch) | |
tree | b905593d0d4acf31a73211b417c5992a19412121 | |
parent | d5b39c9001cdbc67d37ebb841c5fcbdad6f77d32 (diff) | |
download | puppet-aae6e938485e4d3be6b0130153940b2a4f3d6e06.tar.gz |
(PUP-643) Report a puppet warning when pkg warns
-rw-r--r-- | lib/puppet/provider/package/pkg.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/puppet/provider/package/pkg.rb b/lib/puppet/provider/package/pkg.rb index 249e46760..db7c0a008 100644 --- a/lib/puppet/provider/package/pkg.rb +++ b/lib/puppet/provider/package/pkg.rb @@ -126,9 +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"). - select { |line| line !~ /^Certificate/ }. # skip certificate expiration warnings - map { |line| self.class.parse_line(line) } + 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 |