mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-23 19:57:02 +00:00
Add comments on some exported resources
This commit is contained in:
parent
eb6a2b12b7
commit
f64ecad867
5 changed files with 11 additions and 0 deletions
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// FindYamlInDir will find yaml files in folder dir, and send their filenames in batches
|
||||||
|
// of size batchSize to channel fileBatches
|
||||||
func FindYamlInDir(dir string, fileBatches chan<- []string, batchSize int) error {
|
func FindYamlInDir(dir string, fileBatches chan<- []string, batchSize int) error {
|
||||||
files := []string{}
|
files := []string{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ type jsono struct {
|
||||||
nValid, nInvalid, nErrors, nSkipped int
|
nValid, nInvalid, nErrors, nSkipped int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JSON will output the results of the validation as a JSON
|
||||||
func JSON(w io.Writer, withSummary bool, verbose bool) Output {
|
func JSON(w io.Writer, withSummary bool, verbose bool) Output {
|
||||||
return &jsono{
|
return &jsono{
|
||||||
w: w,
|
w: w,
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ type text struct {
|
||||||
nValid, nInvalid, nErrors, nSkipped int
|
nValid, nInvalid, nErrors, nSkipped int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Text will output the results of the validation as a text
|
||||||
func Text(w io.Writer, withSummary, verbose bool) Output {
|
func Text(w io.Writer, withSummary, verbose bool) Output {
|
||||||
return &text{
|
return &text{
|
||||||
w: w,
|
w: w,
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,12 @@ type Manifest struct {
|
||||||
Kind, Version string
|
Kind, Version string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Registry is an interface that should be implemented by any source of Kubernetes schemas
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
DownloadSchema(resourceKind, resourceAPIVersion, k8sVersion string) ([]byte, error)
|
DownloadSchema(resourceKind, resourceAPIVersion, k8sVersion string) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retryable indicates whether an error is a temporary or a permanent failure
|
||||||
type Retryable interface {
|
type Retryable interface {
|
||||||
IsRetryable() bool
|
IsRetryable() bool
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// InvalidResourceError is returned when a resource does not conform to
|
||||||
|
// the associated schema
|
||||||
type InvalidResourceError struct{ err string }
|
type InvalidResourceError struct{ err string }
|
||||||
|
|
||||||
func (r InvalidResourceError) Error() string {
|
func (r InvalidResourceError) Error() string {
|
||||||
|
|
@ -16,6 +18,8 @@ func (r InvalidResourceError) Error() string {
|
||||||
// new formats on the gojsonschema loader
|
// new formats on the gojsonschema loader
|
||||||
type ValidFormat struct{}
|
type ValidFormat struct{}
|
||||||
|
|
||||||
|
// ValidFormat is a type for quickly forcing
|
||||||
|
// new formats on the gojsonschema loader
|
||||||
func (f ValidFormat) IsFormat(input interface{}) bool {
|
func (f ValidFormat) IsFormat(input interface{}) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +32,7 @@ func (f ValidFormat) IsFormat(input interface{}) bool {
|
||||||
// gojsonschema.FormatCheckers.Add("int-or-string", ValidFormat{})
|
// gojsonschema.FormatCheckers.Add("int-or-string", ValidFormat{})
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// Validates a single Kubernetes resource against a Json Schema
|
||||||
func Validate(rawResource []byte, schema *gojsonschema.Schema) error {
|
func Validate(rawResource []byte, schema *gojsonschema.Schema) error {
|
||||||
if schema == nil {
|
if schema == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue