github.com/terraform-modules-krish/terratest@v0.29.0/modules/terraform/errors.go (about) 1 package terraform 2 3 import ( 4 "fmt" 5 ) 6 7 // TgInvalidBinary occurs when a terragrunt function is called and the TerraformBinary is 8 // set to a value other than terragrunt 9 type TgInvalidBinary string 10 11 func (err TgInvalidBinary) Error() string { 12 return fmt.Sprintf("terragrunt must be set as TerraformBinary to use this function. [ TerraformBinary : %s ]", err) 13 } 14 15 // OutputKeyNotFound occurs when terraform output does not contain a value for the key 16 // specified in the function call 17 type OutputKeyNotFound string 18 19 func (err OutputKeyNotFound) Error() string { 20 return fmt.Sprintf("output doesn't contain a value for the key %q", err) 21 } 22 23 // OutputValueNotMap occures when casting a found output value to a map fails 24 type OutputValueNotMap struct { 25 Value interface{} 26 } 27 28 func (err OutputValueNotMap) Error() string { 29 return fmt.Sprintf("Output value %q is not a map", err.Value) 30 } 31 32 // OutputValueNotList occurs when casting a found output value to a 33 // list of interfaces fails 34 type OutputValueNotList struct { 35 Value interface{} 36 } 37 38 func (err OutputValueNotList) Error() string { 39 return fmt.Sprintf("Output value %q is not a list", err.Value) 40 } 41 42 // EmptyOutput is an error that occurs when an output is empty. 43 type EmptyOutput string 44 45 func (outputName EmptyOutput) Error() string { 46 return fmt.Sprintf("Required output %s was empty", string(outputName)) 47 } 48 49 // UnexpectedOutputType is an error that occurs when the output is not of the type we expect 50 type UnexpectedOutputType struct { 51 Key string 52 ExpectedType string 53 ActualType string 54 } 55 56 func (err UnexpectedOutputType) Error() string { 57 return fmt.Sprintf("Expected output '%s' to be of type '%s' but got '%s'", err.Key, err.ExpectedType, err.ActualType) 58 }