validator

package
v0.6.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 10

Documentation

Overview

This is the main package to import to embed kubeconform in your software

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opts added in v0.3.0

type Opts struct {
	Cache                string              // Cache schemas downloaded via HTTP to this folder
	Debug                bool                // Debug infos will be print here
	SkipTLS              bool                // skip TLS validation when downloading from an HTTP Schema Registry
	SkipKinds            map[string]struct{} // List of resource Kinds to ignore
	RejectKinds          map[string]struct{} // List of resource Kinds to reject
	KubernetesVersion    string              // Kubernetes Version - has to match one in https://github.com/instrumenta/kubernetes-json-schema
	Strict               bool                // thros an error if resources contain undocumented fields
	IgnoreMissingSchemas bool                // skip a resource if no schema for that resource can be found
}

Opts contains a set of options for the validator.

type Result added in v0.3.0

type Result struct {
	Resource         resource.Resource
	Err              error
	Status           Status
	ValidationErrors []ValidationError
}

Result contains the details of the result of a resource validation

type Status added in v0.3.0

type Status int

Different types of validation results

const (
	Error   Status // an error occurred processing the file / resource
	Skipped        // resource has been skipped, for example if its Kind was part of the kinds to skip
	Valid          // resource is valid
	Invalid        // resource is invalid
	Empty          // resource is empty. Note: is triggered for files starting with a --- separator.
)

type ValidationError added in v0.6.0

type ValidationError struct {
	Path string `json:"path"`
	Msg  string `json:"msg"`
}

func (*ValidationError) Error added in v0.6.0

func (ve *ValidationError) Error() string

type Validator added in v0.3.0

type Validator interface {
	ValidateResource(res resource.Resource) Result
	Validate(filename string, r io.ReadCloser) []Result
	ValidateWithContext(ctx context.Context, filename string, r io.ReadCloser) []Result
}

Validator exposes multiple methods to validate your Kubernetes resources.

func New added in v0.3.0

func New(schemaLocations []string, opts Opts) (Validator, error)

New returns a new Validator

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL