Documentation ¶
Index ¶
- func AddJSONObject(ctx Interface, data interface{}) error
- func AddOldResource(ctx Interface, dataRaw []byte) error
- func AddResource(ctx Interface, dataRaw []byte) error
- func MutateResourceWithImageInfo(raw []byte, ctx Interface) error
- func ReplaceOldResource(ctx Interface, data map[string]interface{}) error
- func ReplaceResource(ctx Interface, data map[string]interface{}) error
- type EvalInterface
- type Interface
- type InvalidVariableErr
- type MockContext
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
func MutateResourceWithImageInfo ¶ added in v1.4.2
MutateResourceWithImageInfo will set images to their canonical form so that they can be compared in a predictable manner. This sets the default registry as `docker.io` and the tag as `latest` if these are missing.
func ReplaceOldResource ¶ added in v1.7.0
func ReplaceResource ¶ added in v1.7.0
Types ¶
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 // 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 int) error // AddImageInfo adds image info to the context AddImageInfo(info apiutils.ImageInfo) error // AddImageInfos adds image infos to the context AddImageInfos(resource *unstructured.Unstructured) error // 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) (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
func NewContextFromRaw ¶ added in v1.7.0
NewContextFromRaw returns a new context initialized with raw data
type InvalidVariableErr ¶ added in v1.3.4
type InvalidVariableErr struct {
// contains filtered or unexported fields
}
InvalidVariableErr represents error for non-white-listed variables
func (InvalidVariableErr) Error ¶ added in v1.3.4
func (i InvalidVariableErr) 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