class Terraspace::Shell::Error
Attributes
lines[RW]
Public Class Methods
new()
click to toggle source
# File lib/terraspace/shell/error.rb, line 4 def initialize @lines = '' # holds aggregation of all error lines end
Public Instance Methods
bucket_not_found?()
click to toggle source
# 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 message.include?("Failed to get existing workspaces") end
instance()
click to toggle source
# File lib/terraspace/shell/error.rb, line 12 def instance if reinit_required? Terraspace::InitRequiredError.new(@lines) elsif bucket_not_found? Terraspace::BucketNotFoundError.new(@lines) elsif shared_cache_error? Terraspace::SharedCacheError.new(@lines) end end
known?()
click to toggle source
# File lib/terraspace/shell/error.rb, line 8 def known? !!instance end
message()
click to toggle source
# File lib/terraspace/shell/error.rb, line 36 def message @lines.gsub("\n", ' ').squeeze(' ') # remove double whitespaces and newlines end
reinit_required?()
click to toggle source
# File lib/terraspace/shell/error.rb, line 27 def reinit_required? # Example error: https://gist.github.com/tongueroo/f7e0a44b64f0a2e533089b18f331c21e general_check = message.include?("terraform init") && message.include?("Error:") general_check || message.include?("reinitialization required") || message.include?("terraform init") || message.include?("require reinitialization") end