schema

package
v0.0.0-...-c2efb00 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Name is the name of the driver.
	Name = "K8sNativeValidation"
	// ReservedPrefix signifies a prefix that no user-defined value (variable, matcher, etc.) is allowed to have.
	// This gives us the ability to add new variables in the future without worrying about breaking pre-existing templates.
	ReservedPrefix = "gatekeeper_internal_"
	// ParamsName is the VAP variable constraint parameters will be bound to.
	ParamsName = "params"
)

Variables

View Source
var (
	ErrBadMatchCondition = errors.New("invalid match condition")
	ErrBadVariable       = errors.New("invalid variable definition")
	ErrBadFailurePolicy  = errors.New("invalid failure policy")
)
View Source
var (
	ErrBadType      = errors.New("Could not recognize the type")
	ErrMissingField = errors.New("K8sNativeValidation source missing required field")
)

Functions

This section is empty.

Types

type MatchCondition

type MatchCondition struct {
	Name       string `json:"name"`
	Expression string `json:"expression"`
}

type Source

type Source struct {
	// Validations maps to ValidatingAdmissionPolicy's `spec.validations`.
	Validations []Validation `json:"validations,omitempty"`

	// FailurePolicy maps to ValidatingAdmissionPolicy's `spec.failurePolicy`.
	FailurePolicy *string `json:"failurePolicy,omitempty"`

	// MatchConditions maps to ValidatingAdmissionPolicy's `spec.matchConditions`.
	MatchConditions []MatchCondition `json:"matchCondition,omitempty"`

	// Variables maps to ValidatingAdmissionPolicy's `spec.variables`.
	Variables []Variable `json:"variables,omitempty"`
}

func GetSource

func GetSource(code templates.Code) (*Source, error)

func GetSourceFromTemplate

func GetSourceFromTemplate(ct *templates.ConstraintTemplate) (*Source, error)

func (*Source) GetFailurePolicy

func (in *Source) GetFailurePolicy() (*admissionv1.FailurePolicyType, error)

func (*Source) GetMatchConditions

func (in *Source) GetMatchConditions() ([]cel.ExpressionAccessor, error)

func (*Source) GetMessageExpressions

func (in *Source) GetMessageExpressions() ([]cel.ExpressionAccessor, error)

func (*Source) GetV1Beta1FailurePolicy

func (in *Source) GetV1Beta1FailurePolicy() (*admissionv1beta1.FailurePolicyType, error)

func (*Source) GetV1Beta1MatchConditions

func (in *Source) GetV1Beta1MatchConditions() ([]admissionv1beta1.MatchCondition, error)

func (*Source) GetV1Beta1Validatons

func (in *Source) GetV1Beta1Validatons() ([]admissionv1beta1.Validation, error)

func (*Source) GetV1Beta1Variables

func (in *Source) GetV1Beta1Variables() ([]admissionv1beta1.Variable, error)

func (*Source) GetValidations

func (in *Source) GetValidations() ([]cel.ExpressionAccessor, error)

func (*Source) GetVariables

func (in *Source) GetVariables() ([]cel.NamedExpressionAccessor, error)

func (*Source) MustToUnstructured

func (in *Source) MustToUnstructured() map[string]interface{}

ToUnstructured() is a convenience method for converting to unstructured. Intended for testing. It will panic on error.

func (*Source) Validate

func (in *Source) Validate() error

type Validation

type Validation struct {
	// A CEL expression. Maps to ValidationAdmissionPolicy's `spec.validations`.
	Expression        string `json:"expression,omitempty"`
	Message           string `json:"message,omitempty"`
	MessageExpression string `json:"messageExpression,omitempty"`
}

type Variable

type Variable struct {
	// A CEL variable definition. Maps to ValidationAdmissionPolicy's `spec.variables`.
	Name       string `json:"name,omitempty"`
	Expression string `json:"expression,omitempty"`
}

Jump to

Keyboard shortcuts

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