Class: Kafo::PuppetFailedResource
- Inherits:
-
Object
- Object
- Kafo::PuppetFailedResource
- Defined in:
- lib/kafo/puppet_failed_resource.rb
Instance Method Summary collapse
-
#event_messages ⇒ Array[String]
The event messages.
-
#initialize(status, logs) ⇒ PuppetFailedResource
constructor
A new instance of PuppetFailedResource.
-
#log_messages ⇒ Array[String]
A collection of Puppet log messages.
-
#log_messages_by_source ⇒ Hash[String, Array[String]]
A collection of Puppet log messages grouped by source.
-
#resource ⇒ String
A resource.
-
#title ⇒ String
A resource title.
- #to_s ⇒ Object
-
#type ⇒ String
A resource type.
Constructor Details
#initialize(status, logs) ⇒ PuppetFailedResource
Returns a new instance of PuppetFailedResource.
7 8 9 10 |
# File 'lib/kafo/puppet_failed_resource.rb', line 7 def initialize(status, logs) @status = status @logs = logs end |
Instance Method Details
#event_messages ⇒ Array[String]
Returns The event messages.
38 39 40 |
# File 'lib/kafo/puppet_failed_resource.rb', line 38 def @status['events'].map { |event| event['message'] } end |
#log_messages ⇒ Array[String]
A collection of Puppet log messages
The log messages include detailed information of what failed. Some debug information, such as timing but crucially the command output, both stdout and stderr.
49 50 51 |
# File 'lib/kafo/puppet_failed_resource.rb', line 49 def @logs.map { |log| log['message'] } end |
#log_messages_by_source ⇒ Hash[String, Array[String]]
A collection of Puppet log messages grouped by source
The log messages include detailed information of what failed. Some debug information, such as timing but crucially the command output, both stdout and stderr.
A resource can have multiple sources. For example, exec can have both unless and returns. Combining the output of those can be confusing, so this presents them separate.
64 65 66 |
# File 'lib/kafo/puppet_failed_resource.rb', line 64 def @logs.group_by { |log| log['source'] }.transform_values { |logs| logs.map { |log| log['message'] } } end |
#resource ⇒ String
Returns A resource.
15 16 17 |
# File 'lib/kafo/puppet_failed_resource.rb', line 15 def resource @status['resource'] end |
#title ⇒ String
Returns A resource title.
29 30 31 |
# File 'lib/kafo/puppet_failed_resource.rb', line 29 def title @status['title'] end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/kafo/puppet_failed_resource.rb', line 33 def to_s "Puppet #{type} resource '#{title}'" end |
#type ⇒ String
Returns A resource type.
22 23 24 |
# File 'lib/kafo/puppet_failed_resource.rb', line 22 def type @status['resource_type'] end |