Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddJSONObject ¶ added in v1.7.0
AddJSONObject merges json data
func AddOldResource ¶ added in v1.7.0
func AddResource ¶ added in v1.7.0
Types ¶
type DeferredLoader ¶ added in v1.10.0
type DeferredLoader func() error
DeferredLoader loads the context data on first use (query)
type EvalInterface ¶
type EvalInterface interface { // Query accepts a JMESPath expression and returns matching data Query(query string) (interface{}, error) // HasChanged accepts a JMESPath expression and compares matching data in the // request.object and request.oldObject context fields. If the data has changed // it return `true`. If the data has not changed it returns false. If either // request.object or request.oldObject are not found, an error is returned. HasChanged(jmespath string) (bool, error) }
EvalInterface is used to query and inspect context data
type Interface ¶
type Interface interface { // AddRequest marshals and adds the admission request to the context AddRequest(request admissionv1.AdmissionRequest) error // AddVariable adds a variable to the context AddVariable(key string, value interface{}) error // AddContextEntry adds a context entry to the context AddContextEntry(name string, dataRaw []byte) error // ReplaceContextEntry replaces a context entry to the context ReplaceContextEntry(name string, dataRaw []byte) error // AddResource merges resource json under request.object AddResource(data map[string]interface{}) error // AddOldResource merges resource json under request.oldObject AddOldResource(data map[string]interface{}) error // AddTargetResource merges resource json under target AddTargetResource(data map[string]interface{}) error // AddOperation merges operation under request.operation AddOperation(data string) error // AddUserInfo merges userInfo json under kyverno.userInfo AddUserInfo(userInfo kyvernov1beta1.RequestInfo) error // AddServiceAccount merges ServiceAccount types AddServiceAccount(userName string) error // AddNamespace merges resource json under request.namespace AddNamespace(namespace string) error // AddElement adds element info to the context AddElement(data interface{}, index, nesting int) error // AddImageInfo adds image info to the context AddImageInfo(info apiutils.ImageInfo, cfg config.Configuration) error // AddImageInfos adds image infos to the context AddImageInfos(resource *unstructured.Unstructured, cfg config.Configuration) error // AddDeferredLoader adds a loader that is executed on first use (query) AddDeferredLoader(name string, loader DeferredLoader) // ImageInfo returns image infos present in the context ImageInfo() map[string]map[string]apiutils.ImageInfo // GenerateCustomImageInfo returns image infos as defined by a custom image extraction config // and updates the context GenerateCustomImageInfo(resource *unstructured.Unstructured, imageExtractorConfigs kyvernov1.ImageExtractorConfigs, cfg config.Configuration) (map[string]map[string]apiutils.ImageInfo, error) // Checkpoint creates a copy of the current internal state and pushes it into a stack of stored states. Checkpoint() // Restore sets the internal state to the last checkpoint, and removes the checkpoint. Restore() // Reset sets the internal state to the last checkpoint, but does not remove the checkpoint. Reset() EvalInterface // contains filtered or unexported methods }
Interface to manage context operations
type InvalidVariableError ¶ added in v1.8.0
type InvalidVariableError struct {
// contains filtered or unexported fields
}
InvalidVariableError represents error for non-white-listed variables
func (InvalidVariableError) Error ¶ added in v1.8.0
func (i InvalidVariableError) Error() string
type MockContext ¶ added in v1.5.2
type MockContext struct {
// contains filtered or unexported fields
}
MockContext is used for testing and validation of variables
func NewMockContext ¶ added in v1.5.2
func NewMockContext(re *regexp.Regexp, vars ...string) *MockContext
NewMockContext creates a new MockContext that allows variables matching the supplied list of wildcard patterns
func (*MockContext) AddVariable ¶ added in v1.5.2
func (ctx *MockContext) AddVariable(wildcardPattern string)
AddVariable adds given wildcardPattern to the allowed variable patterns
func (*MockContext) HasChanged ¶ added in v1.5.2
func (ctx *MockContext) HasChanged(_ string) (bool, error)
func (*MockContext) Query ¶ added in v1.5.2
func (ctx *MockContext) Query(query string) (interface{}, error)
Query the JSON context with JMESPATH search path
Click to show internal directories.
Click to hide internal directories.