Paired-with: Jesse Wolfe <[email protected]>
Signed-off-by: Paul Berry <[email protected]>
---
Local-branch: ticket/next/5743
lib/report_transformer.rb | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/lib/report_transformer.rb b/lib/report_transformer.rb
index e4fdd46..72c5d17 100644
--- a/lib/report_transformer.rb
+++ b/lib/report_transformer.rb
@@ -56,7 +56,14 @@ class ReportTransformer::OneToTwo <
ReportTransformer::ReportTransformation
report["metrics"]["time"]["total"] = report["metrics"]["time"].values.sum
end
- report["status"] = failed_resources?(report) ? 'failed' :
changed_resources?(report) ? 'changed' : 'unchanged'
+ report["status"] = case
+ when has_no_metrics?(report) || failed_resources?(report)
+ 'failed'
+ when changed_resources?(report)
+ 'changed'
+ else
+ 'unchanged'
+ end
report["configuration_version"] =
configuration_version_from_resource_statuses(report) ||
configuration_version_from_log_objects(report) ||
configuration_version_from_log_message(report)
report["kind"] = "apply"
report["puppet_version"] ||= puppet_version(report) # If it started as a
v0 report, we've already filled in puppet_version
@@ -81,13 +88,24 @@ class ReportTransformer::OneToTwo <
ReportTransformer::ReportTransformation
report
end
+ def self.has_no_metrics?(report)
+ report["metrics"].empty?
+ end
+
def self.failed_resources?(report)
- return true if report["metrics"].empty?
- (report["metrics"]["resources"] and
report["metrics"]["resources"]["failed"] or 0) > 0
+ if report["metrics"]["resources"] and
report["metrics"]["resources"]["failed"]
+ report["metrics"]["resources"]["failed"] > 0
+ else
+ false
+ end
end
def self.changed_resources?(report)
- (report["metrics"] and report["metrics"]["changes"] and
report["metrics"]["changes"]["total"] or 0) > 0
+ if report["metrics"]["changes"] and report["metrics"]["changes"]["total"]
+ report["metrics"]["changes"]["total"] > 0
+ else
+ false
+ end
end
def self.puppet_version(report)
--
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.