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