Class: Pangea::CLI::TofuEvents::Event
- Defined in:
- lib/pangea/cli/tofu_events.rb
Overview
One parsed event from the NDJSON stream.
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #change ⇒ Object
- #changes ⇒ Object
- #diagnostic ⇒ Object
- #diagnostic? ⇒ Boolean
- #dropped_warning? ⇒ Boolean
- #hook ⇒ Object
-
#initialize(hash) ⇒ Event
constructor
A new instance of Event.
- #level ⇒ Object
- #message ⇒ Object
- #operation ⇒ Object
- #resource_address ⇒ Object
- #timestamp ⇒ Object
- #transient_error? ⇒ Boolean
- #type ⇒ Object
Constructor Details
#initialize(hash) ⇒ Event
Returns a new instance of Event.
51 52 53 |
# File 'lib/pangea/cli/tofu_events.rb', line 51 def initialize(hash) @raw = hash end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
49 50 51 |
# File 'lib/pangea/cli/tofu_events.rb', line 49 def raw @raw end |
Instance Method Details
#change ⇒ Object
61 |
# File 'lib/pangea/cli/tofu_events.rb', line 61 def change = @raw['change'] |
#changes ⇒ Object
62 |
# File 'lib/pangea/cli/tofu_events.rb', line 62 def changes = @raw['changes'] |
#diagnostic ⇒ Object
59 |
# File 'lib/pangea/cli/tofu_events.rb', line 59 def diagnostic = @raw['diagnostic'] |
#diagnostic? ⇒ Boolean
65 |
# File 'lib/pangea/cli/tofu_events.rb', line 65 def diagnostic? = type == 'diagnostic' |
#dropped_warning? ⇒ Boolean
75 76 77 78 79 80 81 |
# File 'lib/pangea/cli/tofu_events.rb', line 75 def dropped_warning? return false unless diagnostic? d = diagnostic return false if d.nil? || d['severity'] != 'warning' summary = d['summary'].to_s DROPPED_WARNING_PATTERNS.any? { |p| summary.match?(p) } end |
#hook ⇒ Object
60 |
# File 'lib/pangea/cli/tofu_events.rb', line 60 def hook = @raw['hook'] |
#level ⇒ Object
56 |
# File 'lib/pangea/cli/tofu_events.rb', line 56 def level = @raw['@level'] |
#message ⇒ Object
57 |
# File 'lib/pangea/cli/tofu_events.rb', line 57 def = @raw['@message'] |
#operation ⇒ Object
63 |
# File 'lib/pangea/cli/tofu_events.rb', line 63 def operation = @raw['operation'] |
#resource_address ⇒ Object
83 84 85 86 |
# File 'lib/pangea/cli/tofu_events.rb', line 83 def resource_address (hook || {}).dig('resource', 'addr') \ || (change || {}).dig('resource', 'addr') end |
#timestamp ⇒ Object
58 |
# File 'lib/pangea/cli/tofu_events.rb', line 58 def = @raw['@timestamp'] |
#transient_error? ⇒ Boolean
67 68 69 70 71 72 73 |
# File 'lib/pangea/cli/tofu_events.rb', line 67 def transient_error? return false unless diagnostic? d = diagnostic return false if d.nil? || d['severity'] != 'error' blob = "#{d['summary']} #{d['detail']}" TRANSIENT_ERROR_PATTERNS.any? { |p| blob.match?(p) } end |
#type ⇒ Object
55 |
# File 'lib/pangea/cli/tofu_events.rb', line 55 def type = @raw['type'] |