diff --git a/pkg/fsutils/findyaml.go b/pkg/fsutils/findyaml.go index 40b5686..f32a57f 100644 --- a/pkg/fsutils/findyaml.go +++ b/pkg/fsutils/findyaml.go @@ -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{} diff --git a/pkg/output/json.go b/pkg/output/json.go index 338c2e8..3e3f7cf 100644 --- a/pkg/output/json.go +++ b/pkg/output/json.go @@ -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, diff --git a/pkg/output/text.go b/pkg/output/text.go index 16455bd..fc19b68 100644 --- a/pkg/output/text.go +++ b/pkg/output/text.go @@ -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, diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index 04d6f0f..6dd932e 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -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 } diff --git a/pkg/validator/validator.go b/pkg/validator/validator.go index 3c76226..bc6fc8d 100644 --- a/pkg/validator/validator.go +++ b/pkg/validator/validator.go @@ -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