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
- #state_lock_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
24 25 26 27 |
# File 'lib/terraspace/shell/error.rb', line 24 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 21 22 |
# File 'lib/terraspace/shell/error.rb', line 12 def instance if reinit_required? Terraspace::InitRequiredError.new() elsif bucket_not_found? Terraspace::BucketNotFoundError.new() elsif shared_cache_error? Terraspace::SharedCacheError.new() elsif state_lock_error? Terraspace::StateLockError.new() end end |
#known? ⇒ Boolean
8 9 10 |
# File 'lib/terraspace/shell/error.rb', line 8 def known? !!instance end |
#message ⇒ Object
38 39 40 41 |
# File 'lib/terraspace/shell/error.rb', line 38 def # For error messages, terraform lines from buffer do not contain newlines. So join with newline @lines.map { |l| l.force_encoding('UTF-8') }.join("\n") end |
#reinit_required? ⇒ Boolean
29 30 31 32 33 34 35 36 |
# File 'lib/terraspace/shell/error.rb', line 29 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
43 44 45 46 47 |
# File 'lib/terraspace/shell/error.rb', line 43 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 |
#state_lock_error? ⇒ Boolean
49 50 51 52 |
# File 'lib/terraspace/shell/error.rb', line 49 def state_lock_error? # Example: https://gist.github.com/tongueroo/6bcb86f88053c58fa50f434789268b78 .include?("Error acquiring the state lock") end |