-
Notifications
You must be signed in to change notification settings - Fork 5
/
shared_code.go.tpl
107 lines (83 loc) · 3.28 KB
/
shared_code.go.tpl
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
104
105
106
107
// attrReadMissingDiag represents diagnostic message on an attribute missing in the source object
type attrReadMissingDiag struct {
Path string
}
func (d attrReadMissingDiag) Severity() diag.Severity {
return diag.SeverityError
}
func (d attrReadMissingDiag) Summary() string {
return "Error reading from Terraform object"
}
func (d attrReadMissingDiag) Detail() string {
return fmt.Sprintf("A value for %v is missing in the source Terraform object Attrs", d.Path)
}
func (d attrReadMissingDiag) Equal(o diag.Diagnostic) bool {
return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail())
}
// attrReadConversionFailureDiag represents diagnostic message on a failed type conversion on read
type attrReadConversionFailureDiag struct {
Path string
Type string
}
func (d attrReadConversionFailureDiag) Severity() diag.Severity {
return diag.SeverityError
}
func (d attrReadConversionFailureDiag) Summary() string {
return "Error reading from Terraform object"
}
func (d attrReadConversionFailureDiag) Detail() string {
return fmt.Sprintf("A value for %v can not be converted to %v", d.Path, d.Type)
}
func (d attrReadConversionFailureDiag) Equal(o diag.Diagnostic) bool {
return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail())
}
// attrWriteMissingDiag represents diagnostic message on an attribute missing in the target object
type attrWriteMissingDiag struct {
Path string
}
func (d attrWriteMissingDiag) Severity() diag.Severity {
return diag.SeverityError
}
func (d attrWriteMissingDiag) Summary() string {
return "Error writing to Terraform object"
}
func (d attrWriteMissingDiag) Detail() string {
return fmt.Sprintf("A value for %v is missing in the source Terraform object AttrTypes", d.Path)
}
func (d attrWriteMissingDiag) Equal(o diag.Diagnostic) bool {
return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail())
}
// attrWriteConversionFailureDiag represents diagnostic message on a failed type conversion on write
type attrWriteConversionFailureDiag struct {
Path string
Type string
}
func (d attrWriteConversionFailureDiag) Severity() diag.Severity {
return diag.SeverityError
}
func (d attrWriteConversionFailureDiag) Summary() string {
return "Error writing to Terraform object"
}
func (d attrWriteConversionFailureDiag) Detail() string {
return fmt.Sprintf("A value for %v can not be converted to %v", d.Path, d.Type)
}
func (d attrWriteConversionFailureDiag) Equal(o diag.Diagnostic) bool {
return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail())
}
// attrWriteGeneralError represents diagnostic message on a generic error on write
type attrWriteGeneralError struct {
Path string
Err error
}
func (d attrWriteGeneralError) Severity() diag.Severity {
return diag.SeverityError
}
func (d attrWriteGeneralError) Summary() string {
return "Error writing to Terraform object"
}
func (d attrWriteGeneralError) Detail() string {
return fmt.Sprintf("%s: %s", d.Path, d.Err.Error())
}
func (d attrWriteGeneralError) Equal(o diag.Diagnostic) bool {
return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail())
}