2020-01-07 18:33:28 +00:00
|
|
|
package generate
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
2020-01-24 20:05:53 +00:00
|
|
|
// ParseFailed stores the resource that failed to parse
|
2020-01-07 18:33:28 +00:00
|
|
|
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())
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:05:53 +00:00
|
|
|
//NewParseFailed returns a new ParseFailed error
|
2020-01-07 18:33:28 +00:00
|
|
|
func NewParseFailed(spec interface{}, err error) *ParseFailed {
|
|
|
|
return &ParseFailed{spec: spec, parseError: err}
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:05:53 +00:00
|
|
|
//Violation stores the rule that violated
|
2020-01-07 18:33:28 +00:00
|
|
|
type Violation struct {
|
|
|
|
rule string
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *Violation) Error() string {
|
|
|
|
return fmt.Sprintf("creating Violation; error %s", e.err)
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:05:53 +00:00
|
|
|
//NewViolation returns a new Violation error
|
2020-01-07 18:33:28 +00:00
|
|
|
func NewViolation(rule string, err error) *Violation {
|
|
|
|
return &Violation{rule: rule, err: err}
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:05:53 +00:00
|
|
|
// NotFound stores the resource that was not found
|
2020-01-07 18:33:28 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:05:53 +00:00
|
|
|
//NewNotFound returns a new NotFound error
|
2020-01-07 18:33:28 +00:00
|
|
|
func NewNotFound(kind, namespace, name string) *NotFound {
|
|
|
|
return &NotFound{kind: kind, namespace: namespace, name: name}
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:05:53 +00:00
|
|
|
//ConfigNotFound stores the config information
|
2020-01-07 18:33:28 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:05:53 +00:00
|
|
|
//NewConfigNotFound returns a new NewConfigNotFound error
|
2020-01-07 18:33:28 +00:00
|
|
|
func NewConfigNotFound(config interface{}, kind, namespace, name string) *ConfigNotFound {
|
|
|
|
return &ConfigNotFound{config: config, kind: kind, namespace: namespace, name: name}
|
|
|
|
}
|