mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 02:20:53 +00:00
update results field of ResourceList to implement function spec v1
This commit is contained in:
@@ -23,25 +23,30 @@ const (
|
||||
)
|
||||
|
||||
// ResultItem defines a validation result
|
||||
type ResultItem struct {
|
||||
// Message is a human readable message
|
||||
Message string `yaml:"message,omitempty"`
|
||||
type Result struct {
|
||||
// Message is a human readable message. This field is required.
|
||||
Message string `yaml:"message,omitempty" json:"message,omitempty"`
|
||||
|
||||
// Severity is the severity of this result
|
||||
Severity Severity `yaml:"severity,omitempty"`
|
||||
Severity Severity `yaml:"severity,omitempty" json:"severity,omitempty"`
|
||||
|
||||
// ResourceRef is a reference to a resource
|
||||
ResourceRef yaml.ResourceIdentifier `yaml:"resourceRef,omitempty"`
|
||||
// ResourceRef is a reference to a resource.
|
||||
// Required fields: apiVersion, kind, name.
|
||||
ResourceRef yaml.ResourceIdentifier `yaml:"resourceRef,omitempty" json:"resourceRef,omitempty"`
|
||||
|
||||
// Field is a reference to the field in a resource this result refers to
|
||||
Field Field `yaml:"field,omitempty"`
|
||||
Field Field `yaml:"field,omitempty" json:"field,omitempty"`
|
||||
|
||||
// File references a file containing the resource this result refers to
|
||||
File File `yaml:"file,omitempty"`
|
||||
File File `yaml:"file,omitempty" json:"file,omitempty"`
|
||||
|
||||
// Tags is an unstructured key value map stored with a result that may be set
|
||||
// by external tools to store and retrieve arbitrary metadata
|
||||
Tags map[string]string `yaml:"tags,omitempty" json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// String provides a human-readable message for the result item
|
||||
func (i ResultItem) String() string {
|
||||
func (i Result) String() string {
|
||||
identifier := i.ResourceRef
|
||||
var idStringList []string
|
||||
if identifier.APIVersion != "" {
|
||||
@@ -65,47 +70,41 @@ func (i ResultItem) String() string {
|
||||
|
||||
// File references a file containing a resource
|
||||
type File struct {
|
||||
// Path is relative path to the file containing the resource
|
||||
Path string `yaml:"path,omitempty"`
|
||||
// Path is relative path to the file containing the resource.
|
||||
// This field is required.
|
||||
Path string `yaml:"path,omitempty" json:"path,omitempty"`
|
||||
|
||||
// Index is the index into the file containing the resource
|
||||
// (i.e. if there are multiple resources in a single file)
|
||||
Index int `yaml:"index,omitempty"`
|
||||
Index int `yaml:"index,omitempty" json:"index,omitempty"`
|
||||
}
|
||||
|
||||
// Field references a field in a resource
|
||||
type Field struct {
|
||||
// Path is the field path
|
||||
Path string `yaml:"path,omitempty"`
|
||||
// Path is the field path. This field is required.
|
||||
Path string `yaml:"path,omitempty" json:"path,omitempty"`
|
||||
|
||||
// CurrentValue is the current field value
|
||||
CurrentValue string `yaml:"currentValue,omitempty"`
|
||||
CurrentValue interface{} `yaml:"currentValue,omitempty" json:"currentValue,omitempty"`
|
||||
|
||||
// SuggestedValue is the suggested field value
|
||||
SuggestedValue string `yaml:"suggestedValue,omitempty"`
|
||||
// ProposedValue is the proposed value of the field to fix an issue.
|
||||
ProposedValue interface{} `yaml:"proposedValue,omitempty" json:"proposedValue,omitempty"`
|
||||
}
|
||||
|
||||
// Result defines a function result which will be set on the emitted ResourceList
|
||||
type Result struct {
|
||||
// Name is the name of the function creating the result
|
||||
Name string `yaml:"name,omitempty"`
|
||||
type Results []*Result
|
||||
|
||||
// Items are the individual results
|
||||
Items []ResultItem `yaml:"items,omitempty"`
|
||||
}
|
||||
|
||||
// Error enables a Result to be returned as an error
|
||||
func (e Result) Error() string {
|
||||
// Error enables Results to be returned as an error
|
||||
func (e Results) Error() string {
|
||||
var msgs []string
|
||||
for _, i := range e.Items {
|
||||
for _, i := range e {
|
||||
msgs = append(msgs, i.String())
|
||||
}
|
||||
return strings.Join(msgs, "\n\n")
|
||||
}
|
||||
|
||||
// ExitCode provides the exit code based on the result's severity
|
||||
func (e Result) ExitCode() int {
|
||||
for _, i := range e.Items {
|
||||
func (e Results) ExitCode() int {
|
||||
for _, i := range e {
|
||||
if i.Severity == Error {
|
||||
return 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user