forked from kyverno/kyverno
/
errors.go
59 lines (46 loc) · 1.35 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
package generate
import "fmt"
// DATA
type ParseFailed struct {
spec interface{}
parseError error
}
func (e *ParseFailed) Error() string {
return fmt.Sprintf("failed to parse the resource spec %v: %v", e.spec, e.parseError.Error())
}
func NewParseFailed(spec interface{}, err error) *ParseFailed {
return &ParseFailed{spec: spec, parseError: err}
}
type Violation struct {
rule string
err error
}
func (e *Violation) Error() string {
return fmt.Sprintf("creating Violation; error %s", e.err)
}
func NewViolation(rule string, err error) *Violation {
return &Violation{rule: rule, err: err}
}
type NotFound struct {
kind string
namespace string
name string
}
func (e *NotFound) Error() string {
return fmt.Sprintf("resource %s/%s/%s not present", e.kind, e.namespace, e.name)
}
func NewNotFound(kind, namespace, name string) *NotFound {
return &NotFound{kind: kind, namespace: namespace, name: name}
}
type ConfigNotFound struct {
config interface{}
kind string
namespace string
name string
}
func (e *ConfigNotFound) Error() string {
return fmt.Sprintf("configuration %v, not present in resource %s/%s/%s", e.config, e.kind, e.namespace, e.name)
}
func NewConfigNotFound(config interface{}, kind, namespace, name string) *ConfigNotFound {
return &ConfigNotFound{config: config, kind: kind, namespace: namespace, name: name}
}