Version: v0.16.1 Latest Latest

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

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 13 Imported by: 6




View Source
const DefaultSchemaLocation = "https://kubernetesjsonschema.dev"

DefaultSchemaLocation is the default location to search for schemas

View Source
const OpenShiftSchemaLocation = "https://raw.githubusercontent.com/garethr/openshift-json-schema/master"

OpenShiftSchemaLocation is the alternative location for OpenShift specific schemas


This section is empty.


func AddKubevalFlags

func AddKubevalFlags(cmd *cobra.Command, config *Config) *cobra.Command

AddKubevalFlags adds the default flags for kubeval to cmd

func GetOutputManager

func GetOutputManager(outFmt string) outputManager

func NewSchemaCache

func NewSchemaCache() map[string]*gojsonschema.Schema

NewSchemaCache returns a new schema cache to be used with ValidateWithCache


type Config

type Config struct {
	// DefaultNamespace is the namespace to assume in resources
	// if no namespace is set in `metadata:namespace` (as used with
	// `kubectl apply --namespace ...` or `helm install --namespace ...`,
	// for example)
	DefaultNamespace string

	// KubernetesVersion represents the version of Kubernetes
	// for which we should load the schema
	KubernetesVersion string

	// SchemaLocation is the base URL from which to search for schemas.
	// It can be either a remote location or a local directory
	SchemaLocation string

	// AdditionalSchemaLocations is a list of alternative base URLs from
	// which to search for schemas, given that the desired schema was not
	// found at SchemaLocation
	AdditionalSchemaLocations []string

	// OpenShift represents whether to test against
	// upstream Kubernetes or the OpenShift schemas
	OpenShift bool

	// Strict tells kubeval whether to prohibit properties not in
	// the schema. The API allows them, but kubectl does not
	Strict bool

	// IgnoreMissingSchemas tells kubeval whether to skip validation
	// for resource definitions without an available schema
	IgnoreMissingSchemas bool

	// ExitOnError tells kubeval whether to halt processing upon the
	// first error encountered or to continue, aggregating all errors
	ExitOnError bool

	// KindsToSkip is a list of kubernetes resources types with which to skip
	// schema validation
	KindsToSkip []string

	// KindsToReject is a list of case-sensitive prohibited kubernetes resources types
	KindsToReject []string

	// FileName is the name to be displayed when testing manifests read from stdin
	FileName string

	// OutputFormat is the name of the output formatter which will be used when
	// reporting results to the user.
	OutputFormat string

	// Quiet indicates whether non-results output should be emitted to the applications
	// log.
	Quiet bool

	// InsecureSkipTLSVerify controls whether to skip TLS certificate validation
	// when retrieving schema content over HTTPS
	InsecureSkipTLSVerify bool

A Config object contains various configuration data for kubeval

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig creates a Config with default values

type STDOutputManager

type STDOutputManager struct {

STDOutputManager reports `kubeval` results to stdout.

func (*STDOutputManager) Flush

func (s *STDOutputManager) Flush() error

func (*STDOutputManager) Put

func (s *STDOutputManager) Put(result ValidationResult) error

type ValidFormat

type ValidFormat struct{}

ValidFormat is a type for quickly forcing new formats on the gojsonschema loader

func (ValidFormat) IsFormat

func (f ValidFormat) IsFormat(input interface{}) bool

IsFormat always returns true and meets the gojsonschema.FormatChecker interface

type ValidationResult

type ValidationResult struct {
	FileName               string
	Kind                   string
	APIVersion             string
	ValidatedAgainstSchema bool
	Errors                 []gojsonschema.ResultError
	ResourceName           string
	ResourceNamespace      string

ValidationResult contains the details from validating a given Kubernetes resource

func Validate

func Validate(input []byte, conf ...*Config) ([]ValidationResult, error)

Validate a Kubernetes YAML file, parsing out individual resources and validating them all according to the relevant schemas

func ValidateWithCache

func ValidateWithCache(input []byte, schemaCache map[string]*gojsonschema.Schema, conf ...*Config) ([]ValidationResult, error)

ValidateWithCache validates a Kubernetes YAML file, parsing out individual resources and validating them all according to the relevant schemas Allows passing a kubeval.NewSchemaCache() to cache schemas in-memory between validations

func (*ValidationResult) QualifiedName

func (v *ValidationResult) QualifiedName() string

QualifiedName returns a string of the [namespace.]name of the k8s resource

func (*ValidationResult) VersionKind

func (v *ValidationResult) VersionKind() string

VersionKind returns a string representation of this result's apiVersion and kind

Jump to

Keyboard shortcuts

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