Add comments on some exported resources

This commit is contained in:
Yann Hamon 2020-06-04 00:51:36 +02:00
parent eb6a2b12b7
commit f64ecad867
5 changed files with 11 additions and 0 deletions

View file

@ -6,6 +6,8 @@ import (
"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 {
files := []string{}

View file

@ -22,6 +22,7 @@ type jsono struct {
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 {
return &jsono{
w: w,

View file

@ -14,6 +14,7 @@ type text struct {
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 {
return &text{
w: w,

View file

@ -4,10 +4,12 @@ type Manifest struct {
Kind, Version string
}
// Registry is an interface that should be implemented by any source of Kubernetes schemas
type Registry interface {
DownloadSchema(resourceKind, resourceAPIVersion, k8sVersion string) ([]byte, error)
}
// Retryable indicates whether an error is a temporary or a permanent failure
type Retryable interface {
IsRetryable() bool
}

View file

@ -6,6 +6,8 @@ import (
"sigs.k8s.io/yaml"
)
// InvalidResourceError is returned when a resource does not conform to
// the associated schema
type InvalidResourceError struct{ err string }
func (r InvalidResourceError) Error() string {
@ -16,6 +18,8 @@ func (r InvalidResourceError) Error() string {
// new formats on the gojsonschema loader
type ValidFormat struct{}
// ValidFormat is a type for quickly forcing
// new formats on the gojsonschema loader
func (f ValidFormat) IsFormat(input interface{}) bool {
return true
}
@ -28,6 +32,7 @@ func (f ValidFormat) IsFormat(input interface{}) bool {
// gojsonschema.FormatCheckers.Add("int-or-string", ValidFormat{})
// }
// Validates a single Kubernetes resource against a Json Schema
func Validate(rawResource []byte, schema *gojsonschema.Schema) error {
if schema == nil {
return nil