diff options
| author | Paul Berry <paul@puppetlabs.com> | 2010-12-30 11:01:23 -0800 |
|---|---|---|
| committer | Paul Berry <paul@puppetlabs.com> | 2010-12-30 11:56:23 -0800 |
| commit | 98db2da4e9b35f6260bf07c641550b380b603baa (patch) | |
| tree | bbabd4b8603d4e0b88fa28d3c48848a6dfc5c2a7 | |
| parent | bd4a8a13a85e6d64c987765cb83b1ebd4a63a341 (diff) | |
| download | puppet-98db2da4e9b35f6260bf07c641550b380b603baa.tar.gz puppet-98db2da4e9b35f6260bf07c641550b380b603baa.tar.xz puppet-98db2da4e9b35f6260bf07c641550b380b603baa.zip | |
(#5715) Removed unnecessary attributes from YAML of Puppet::Transaction::Event.
The removed attributes are file, line, resource, tags,
source_description, and default_log_level. These attributes were all
redundant with those in Puppet::Resource::Status.
| -rw-r--r-- | lib/puppet/transaction/event.rb | 5 | ||||
| -rwxr-xr-x | spec/unit/transaction/event_spec.rb | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb index b9fa5c38b..64980f1d9 100644 --- a/lib/puppet/transaction/event.rb +++ b/lib/puppet/transaction/event.rb @@ -8,6 +8,7 @@ class Puppet::Transaction::Event include Puppet::Util::Logging ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :audited] + YAML_ATTRIBUTES = %w{@audited @property @previous_value @desired_value @historical_value @message @name @status @time} attr_accessor *ATTRIBUTES attr_writer :tags attr_accessor :time @@ -47,6 +48,10 @@ class Puppet::Transaction::Event message end + def to_yaml_properties + (YAML_ATTRIBUTES & instance_variables).sort + end + private # If it's a failure, use 'err', else use either the resource's log level (if available) diff --git a/spec/unit/transaction/event_spec.rb b/spec/unit/transaction/event_spec.rb index 2776be8d7..6ed14722b 100755 --- a/spec/unit/transaction/event_spec.rb +++ b/spec/unit/transaction/event_spec.rb @@ -111,4 +111,17 @@ describe Puppet::Transaction::Event do Puppet::Transaction::Event.new(:resource => "Foo[bar]").send_log end end + + describe "When converting to YAML" do + it "should include only documented attributes" do + resource = Puppet::Type.type(:file).new(:title => "/tmp/foo") + event = Puppet::Transaction::Event.new(:source_description => "/my/param", :resource => resource, + :file => "/foo.rb", :line => 27, :tags => %w{one two}, + :desired_value => 7, :historical_value => 'Brazil', + :message => "Help I'm trapped in a spec test", + :name => :mode_changed, :previous_value => 6, :property => :mode, + :status => 'success') + event.to_yaml_properties.should == Puppet::Transaction::Event::YAML_ATTRIBUTES.sort + end + end end |
