Class: Terraspace::Shell::Error
- Inherits:
-
Object
- Object
- Terraspace::Shell::Error
- Defined in:
- lib/terraspace/shell/error.rb
Instance Attribute Summary collapse
-
#lines ⇒ Object
Returns the value of attribute lines.
Instance Method Summary collapse
- #bucket_not_found? ⇒ Boolean
-
#initialize ⇒ Error
constructor
A new instance of Error.
- #instance ⇒ Object
- #known? ⇒ Boolean
- #message ⇒ Object
- #reinit_required? ⇒ Boolean
- #shared_cache_error? ⇒ Boolean
Constructor Details
#initialize ⇒ Error
Returns a new instance of Error.
4 5 6 |
# File 'lib/terraspace/shell/error.rb', line 4 def initialize @lines = '' # holds aggregation of all error lines end |
Instance Attribute Details
#lines ⇒ Object
Returns the value of attribute lines.
3 4 5 |
# File 'lib/terraspace/shell/error.rb', line 3 def lines @lines end |
Instance Method Details
#bucket_not_found? ⇒ Boolean
22 23 24 25 |
# File 'lib/terraspace/shell/error.rb', line 22 def bucket_not_found? # Message is included in aws, azurerm, and google. See: https://bit.ly/3iOKDri .include?("Failed to get existing workspaces") end |
#instance ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/terraspace/shell/error.rb', line 12 def instance if reinit_required? Terraspace::InitRequiredError.new(@lines) elsif bucket_not_found? Terraspace::BucketNotFound.new(@lines) elsif shared_cache_error? Terraspace::SharedCacheError.new(@lines) end end |
#known? ⇒ Boolean
8 9 10 |
# File 'lib/terraspace/shell/error.rb', line 8 def known? !!instance end |
#message ⇒ Object
36 37 38 |
# File 'lib/terraspace/shell/error.rb', line 36 def @lines.gsub("\n", ' ').squeeze(' ') # remove double whitespaces and newlines end |
#reinit_required? ⇒ Boolean
27 28 29 30 31 32 33 34 |
# File 'lib/terraspace/shell/error.rb', line 27 def reinit_required? # Example error: https://gist.github.com/tongueroo/f7e0a44b64f0a2e533089b18f331c21e general_check = .include?("terraform init") && .include?("Error:") general_check || .include?("reinitialization required") || .include?("terraform init") || .include?("require reinitialization") end |
#shared_cache_error? ⇒ Boolean
40 41 42 43 44 |
# File 'lib/terraspace/shell/error.rb', line 40 def shared_cache_error? # Example: https://gist.github.com/tongueroo/4f2c925709d21f5810229ce9ca482560 .include?("Failed to install provider from shared cache") || .include?("Failed to validate installed provider") end |