github.com/mponton/terratest@v0.44.0/modules/terraform/errors.go (about)

     1  package terraform
     2  
     3  import (
     4  	"fmt"
     5  	"reflect"
     6  )
     7  
     8  // TgInvalidBinary occurs when a terragrunt function is called and the TerraformBinary is
     9  // set to a value other than terragrunt
    10  type TgInvalidBinary string
    11  
    12  func (err TgInvalidBinary) Error() string {
    13  	return fmt.Sprintf("terragrunt must be set as TerraformBinary to use this function. [ TerraformBinary : %s ]", string(err))
    14  }
    15  
    16  // OutputKeyNotFound occurs when terraform output does not contain a value for the key
    17  // specified in the function call
    18  type OutputKeyNotFound string
    19  
    20  func (err OutputKeyNotFound) Error() string {
    21  	return fmt.Sprintf("output doesn't contain a value for the key %q", string(err))
    22  }
    23  
    24  // OutputValueNotMap occures when casting a found output value to a map fails
    25  type OutputValueNotMap struct {
    26  	Value interface{}
    27  }
    28  
    29  func (err OutputValueNotMap) Error() string {
    30  	return fmt.Sprintf("Output value %q is not a map", err.Value)
    31  }
    32  
    33  // OutputValueNotList occurs when casting a found output value to a
    34  // list of interfaces fails
    35  type OutputValueNotList struct {
    36  	Value interface{}
    37  }
    38  
    39  func (err OutputValueNotList) Error() string {
    40  	return fmt.Sprintf("Output value %q is not a list", err.Value)
    41  }
    42  
    43  // EmptyOutput is an error that occurs when an output is empty.
    44  type EmptyOutput string
    45  
    46  func (outputName EmptyOutput) Error() string {
    47  	return fmt.Sprintf("Required output %s was empty", string(outputName))
    48  }
    49  
    50  // UnexpectedOutputType is an error that occurs when the output is not of the type we expect
    51  type UnexpectedOutputType struct {
    52  	Key          string
    53  	ExpectedType string
    54  	ActualType   string
    55  }
    56  
    57  func (err UnexpectedOutputType) Error() string {
    58  	return fmt.Sprintf("Expected output '%s' to be of type '%s' but got '%s'", err.Key, err.ExpectedType, err.ActualType)
    59  }
    60  
    61  // VarFileNotFound is an error that occurs when a var file cannot be found in an option's VarFile list
    62  type VarFileNotFound struct {
    63  	Path string
    64  }
    65  
    66  func (err VarFileNotFound) Error() string {
    67  	return fmt.Sprintf("Var file '%s' not found", err.Path)
    68  }
    69  
    70  // InputFileKeyNotFound occurs when tfvar file does not contain a value for the key
    71  // specified in the function call
    72  type InputFileKeyNotFound struct {
    73  	FilePath string
    74  	Key      string
    75  }
    76  
    77  func (err InputFileKeyNotFound) Error() string {
    78  	return fmt.Sprintf("tfvar file %q doesn't contain a value for the key %q", err.FilePath, err.Key)
    79  }
    80  
    81  // PanicWhileParsingVarFile is returned when the HCL parsing routine panics due to errors.
    82  type PanicWhileParsingVarFile struct {
    83  	ConfigFile     string
    84  	RecoveredValue interface{}
    85  }
    86  
    87  func (err PanicWhileParsingVarFile) Error() string {
    88  	return fmt.Sprintf("Recovering panic while parsing '%s'. Got error of type '%v': %v", err.ConfigFile, reflect.TypeOf(err.RecoveredValue), err.RecoveredValue)
    89  }
    90  
    91  // UnsupportedDefaultWorkspaceDeletion is returned when user tries to delete the workspace "default"
    92  type UnsupportedDefaultWorkspaceDeletion struct{}
    93  
    94  func (err *UnsupportedDefaultWorkspaceDeletion) Error() string {
    95  	return "Deleting the workspace 'default' is not supported"
    96  }
    97  
    98  // WorkspaceDoesNotExist is returned when user tries to delete a workspace which does not exist
    99  type WorkspaceDoesNotExist string
   100  
   101  func (err WorkspaceDoesNotExist) Error() string {
   102  	return fmt.Sprintf("The workspace %q does not exist.", string(err))
   103  }