Paired-with: Jesse Wolfe <[email protected]>
Signed-off-by: Paul Berry <[email protected]>
---
Local-branch: ticket/next/5743
lib/puppet/report.rb | 12 ------------
lib/report_transformer.rb | 21 +++++++++++++++++++++
spec/lib/report_transformer_spec.rb | 2 +-
spec/models/report_spec.rb | 8 +++-----
4 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/lib/puppet/report.rb b/lib/puppet/report.rb
index c5d2fe7..57e071c 100644
--- a/lib/puppet/report.rb
+++ b/lib/puppet/report.rb
@@ -133,21 +133,9 @@ module ReportExtensions #:nodoc:
[]
end
- def kind
- "apply"
- end
-
def report_format
0
end
-
- def puppet_version
- "0.25.x"
- end
-
- def configuration_version
- configuration_version_from_log_objects ||
configuration_version_from_log_message
- end
end
module Util
diff --git a/lib/report_transformer.rb b/lib/report_transformer.rb
index 2af6019..290d392 100644
--- a/lib/report_transformer.rb
+++ b/lib/report_transformer.rb
@@ -31,8 +31,29 @@ class ReportTransformer::ZeroToOne <
ReportTransformer::ReportTransformation
def self.transform(report)
report["resource_statuses"] = []
+ report["kind"] = "apply"
+ report["configuration_version"] =
configuration_version_from_log_objects(report) ||
configuration_version_from_log_message(report)
+ report["puppet_version"] = "0.25.x"
report
end
+
+ def self.configuration_version_from_log_objects(report)
+ report["logs"].each do |log|
+ if log["version"] and log["source"] != "Puppet"
+ return log["version"].to_s
+ end
+ end
+ nil
+ end
+
+ def self.configuration_version_from_log_message(report)
+ report["logs"].each do |log|
+ if log["message"] =~ /^Applying configuration version '(.*)'$/
+ return $1
+ end
+ end
+ nil
+ end
end
class ReportTransformer::OneToTwo < ReportTransformer::ReportTransformation
diff --git a/spec/lib/report_transformer_spec.rb
b/spec/lib/report_transformer_spec.rb
index c021404..8c0fdc3 100644
--- a/spec/lib/report_transformer_spec.rb
+++ b/spec/lib/report_transformer_spec.rb
@@ -31,7 +31,7 @@ describe ReportTransformer do
describe "when converting from version 0 to version 1" do
before do
- @report = {"report_format" => 0}
+ @report = {"report_format" => 0, "logs" => []}
end
it "should add an empty array for resource_statuses" do
report = ReportTransformer::ZeroToOne.apply(@report)
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index 6d03675..4657dd8 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -316,11 +316,9 @@ HEREDOC
['notice', "content changed '{md5}6d0007e52f7afb7d5a0650b0ffb8a4d1' to
'unknown checksum'", '//Node[default]/File[/tmp/puppet_test]/content',
['class', 'content', 'default', 'file', 'main', 'node', 'notice'], '2009-11-20
01:08:50', '/tmp/puppet/manifests/site.pp', 4]
]
- pending {
- report.configuration_version.should == '1258679330'
- report.puppet_version.should == '0.25.x'
- report.status.should == 'changed'
- }
+ report.configuration_version.should == '1258679330'
+ report.puppet_version.should == '0.25.x'
+ report.status.should == 'changed'
end
it "should populate report related tables from a 2.6 yaml report" do
--
1.7.2
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.