validator

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectVarName        = "object"
	ParamsVarName        = "params"
	PodMetaVarName       = "podMeta"
	PodSpecVarName       = "podSpec"
	AllContainersVarName = "allContainers"
	APIVersionsVarName   = "apiVersions"
	KubeVersionVarName   = "kubeVersion"
	VariableVarName      = "variables"
)

Variables

This section is empty.

Functions

func ExtractPodSpec

ExtractPodSpec returns the metadata and Pod spec from the given object

func HasPodSpec

func HasPodSpec(u unstructured.Unstructured) bool

HasPodSpec returns true if the given object has a Pod spec

func MatchesPodSpec

func MatchesPodSpec(rules []types.ResourceRule) bool

MatchesPodSpec returns true if any rule matches a Pod spec

Types

type CELValidator

type CELValidator struct {
	// contains filtered or unexported fields
}

CELValidator is a Validator that performs CEL expressions

func (*CELValidator) SetAPIVersions

func (r *CELValidator) SetAPIVersions(apiVersions []string)

func (*CELValidator) SetKubeVersion

func (r *CELValidator) SetKubeVersion(v *version.Info)

func (*CELValidator) Validate

func (r *CELValidator) Validate(obj unstructured.Unstructured, params any) (bool, string, error)

type Validator

type Validator interface {
	Validate(obj unstructured.Unstructured, params any) (bool, string, error)
	SetAPIVersions(apiVersions []string)
	SetKubeVersion(v *version.Info)
}

Validator is an interface that defines a method for validating a k8s unustructured object

func Compile

func Compile(check types.Check, apiResources []*metav1.APIResourceList, kubeVersion *version.Info) (Validator, error)

Compile compiles variables and expressions of the given check and returns a Validator

Jump to

Keyboard shortcuts

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