Documentation ¶
Index ¶
- func ApplyPatchNew(resource, patch []byte) ([]byte, error)
- func ApplyPatches(resource []byte, patches [][]byte) ([]byte, error)
- func ConvertToUnstructured(data []byte) (*unstructured.Unstructured, error)
- func FormAbsolutePath(referencePath, absolutePath string) string
- func JoinPatches(patches [][]byte) []byte
- func MatchesResourceDescription(resource unstructured.Unstructured, rule kyverno.Rule) bool
- func ParseKindFromObject(bytes []byte) string
- func ParseNameFromObject(bytes []byte) string
- func ParseNamespaceFromObject(bytes []byte) string
- func ParseResourceInfoFromObject(rawResource []byte) string
- func ValidateValueWithPattern(value, pattern interface{}) bool
- type Condition
- type ConditionAnchorValidationHandler
- type EngineResponseNew
- func Generate(client *client.Client, policy kyverno.ClusterPolicy, ...) (response EngineResponseNew)
- func Mutate(policy kyverno.ClusterPolicy, resource unstructured.Unstructured) (response EngineResponseNew)
- func Validate(policy kyverno.ClusterPolicy, resource unstructured.Unstructured) (response EngineResponseNew)
- type EngineStats
- type ExistanceAnchorValidationHandler
- type NoAnchorValidationHandler
- type Operator
- type PolicyResponse
- type PolicyStats
- type ResourceSpec
- type RuleResponse
- type RuleStats
- type RuleType
- type ValidationAnchorHandler
- func CreateAnchorHandler(anchor string, pattern interface{}, path string) ValidationAnchorHandler
- func NewConditionAnchorValidationHandler(anchor string, pattern interface{}, path string) ValidationAnchorHandler
- func NewExistanceAnchorValidationHandler(anchor string, pattern interface{}, path string) ValidationAnchorHandler
- func NewNoAnchorValidationHandler(path string) ValidationAnchorHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyPatchNew ¶ added in v0.9.0
ApplyPatchNew ...
func ApplyPatches ¶
ApplyPatches patches given resource with given patches and returns patched document
func ConvertToUnstructured ¶ added in v0.8.0
func ConvertToUnstructured(data []byte) (*unstructured.Unstructured, error)
func FormAbsolutePath ¶ added in v0.4.0
FormAbsolutePath returns absolute path
func JoinPatches ¶
JoinPatches joins array of serialized JSON patches to the single JSONPatch array
func MatchesResourceDescription ¶ added in v0.8.0
func MatchesResourceDescription(resource unstructured.Unstructured, rule kyverno.Rule) bool
MatchesResourceDescription checks if the resource matches resource desription of the rule or not
func ParseKindFromObject ¶ added in v0.5.0
ParseKindFromObject get kind from resource
func ParseNameFromObject ¶
ParseNameFromObject extracts resource name from JSON obj
func ParseNamespaceFromObject ¶
ParseNamespaceFromObject extracts the namespace from the JSON obj
func ParseResourceInfoFromObject ¶ added in v0.7.0
ParseResourceInfoFromObject get kind/namepace/name from resource
func ValidateValueWithPattern ¶
func ValidateValueWithPattern(value, pattern interface{}) bool
ValidateValueWithPattern validates value with operators and wildcards
Types ¶
type ConditionAnchorValidationHandler ¶ added in v0.4.0
type ConditionAnchorValidationHandler struct {
// contains filtered or unexported fields
}
ConditionAnchorValidationHandler performs validation only for array elements that pass condition in the anchor (key): value
func (*ConditionAnchorValidationHandler) Handle ¶ added in v0.4.0
func (cavh *ConditionAnchorValidationHandler) Handle(resourcePart []interface{}, patternPart map[string]interface{}, originPattern interface{}) error
Handle performs validation in context of ConditionAnchorValidationHandler
type EngineResponseNew ¶ added in v0.9.0
type EngineResponseNew struct { // Resource patched with the engine action changes PatchedResource unstructured.Unstructured // Policy Response PolicyResponse PolicyResponse }
EngineResponseNew engine response to the action
func Generate ¶
func Generate(client *client.Client, policy kyverno.ClusterPolicy, ns unstructured.Unstructured) (response EngineResponseNew)
Generate apply generation rules on a resource
func Mutate ¶
func Mutate(policy kyverno.ClusterPolicy, resource unstructured.Unstructured) (response EngineResponseNew)
Mutate performs mutation. Overlay first and then mutation patches
func Validate ¶
func Validate(policy kyverno.ClusterPolicy, resource unstructured.Unstructured) (response EngineResponseNew)
Validate applies validation rules from policy on the resource
func (EngineResponseNew) GetFailedRules ¶ added in v0.9.0
func (er EngineResponseNew) GetFailedRules() []string
GetFailedRules returns failed rules
func (EngineResponseNew) GetPatches ¶ added in v0.9.0
func (er EngineResponseNew) GetPatches() [][]byte
GetPatches returns all the patches joined
func (EngineResponseNew) GetSuccessRules ¶ added in v0.9.0
func (er EngineResponseNew) GetSuccessRules() []string
GetSuccessRules returns success rules
func (EngineResponseNew) IsSuccesful ¶ added in v0.9.0
func (er EngineResponseNew) IsSuccesful() bool
IsSuccesful checks if any rule has failed or not
type EngineStats ¶ added in v0.8.0
type EngineStats struct { // average time required to process the policy rules on a resource ExecutionTime time.Duration // Count of rules that were applied succesfully RulesAppliedCount int }
EngineStats stores in the statistics for a single application of resource
type ExistanceAnchorValidationHandler ¶ added in v0.4.0
type ExistanceAnchorValidationHandler struct {
// contains filtered or unexported fields
}
ExistanceAnchorValidationHandler performs validation only for array elements that pass condition in the anchor AND requires an existance of at least one element that passes this condition ^(key): value
func (*ExistanceAnchorValidationHandler) Handle ¶ added in v0.4.0
func (eavh *ExistanceAnchorValidationHandler) Handle(resourcePart []interface{}, patternPart map[string]interface{}, originPattern interface{}) error
Handle performs validation in context of ExistanceAnchorValidationHandler
type NoAnchorValidationHandler ¶ added in v0.4.0
type NoAnchorValidationHandler struct {
// contains filtered or unexported fields
}
NoAnchorValidationHandler just calls validateMap because no anchors were found in the pattern map
func (*NoAnchorValidationHandler) Handle ¶ added in v0.4.0
func (navh *NoAnchorValidationHandler) Handle(resourcePart []interface{}, patternPart map[string]interface{}, originPattern interface{}) error
Handle performs validation in context of NoAnchorValidationHandler
type Operator ¶
type Operator string
Operator is string alias that represents selection operators enum
type PolicyResponse ¶ added in v0.9.0
type PolicyResponse struct { // policy name Policy string `json:"policy"` // resource details Resource ResourceSpec `json:"resource"` // policy statistics PolicyStats `json:",inline"` // rule response Rules []RuleResponse `json:"rules"` // ValidationFailureAction: audit,enforce(default) ValidationFailureAction string }
PolicyResponse policy application response
type PolicyStats ¶ added in v0.9.0
type PolicyStats struct { // time required to process the policy rules on a resource ProcessingTime time.Duration `json:"processingTime"` // Count of rules that were applied succesfully RulesAppliedCount int `json:"rulesAppliedCount"` }
PolicyStats stores statistics for the single policy application
type ResourceSpec ¶ added in v0.9.0
type ResourceSpec struct { //TODO: support ApiVersion Kind string `json:"kind"` APIVersion string `json:"apiVersion"` Namespace string `json:"namespace"` Name string `json:"name"` }
ResourceSpec resource action applied on
type RuleResponse ¶ added in v0.9.0
type RuleResponse struct { // rule name specified in policy Name string `json:"name"` // rule type (Mutation,Generation,Validation) for Kyverno Policy Type string `json:"type"` // message response from the rule application Message string `json:"message"` // JSON patches, for mutation rules Patches [][]byte `json:"patches,omitempty"` // success/fail Success bool `json:"success"` // statistics RuleStats `json:",inline"` }
RuleResponse details for each rule applicatino
func (RuleResponse) ToString ¶ added in v0.9.0
func (rr RuleResponse) ToString() string
ToString ...
type RuleStats ¶ added in v0.9.0
type RuleStats struct { // time required to appliy the rule on the resource ProcessingTime time.Duration `json:"processingTime"` }
RuleStats stores the statisctis for the single rule application
type ValidationAnchorHandler ¶ added in v0.4.0
type ValidationAnchorHandler interface {
Handle(resourcePart []interface{}, patternPart map[string]interface{}, originPattern interface{}) error
}
ValidationAnchorHandler is an interface that represents a family of anchor handlers for array of maps resourcePart must be an array of dictionaries patternPart must be a dictionary with anchors
func CreateAnchorHandler ¶ added in v0.4.0
func CreateAnchorHandler(anchor string, pattern interface{}, path string) ValidationAnchorHandler
CreateAnchorHandler is a factory that create anchor handlers
func NewConditionAnchorValidationHandler ¶ added in v0.4.0
func NewConditionAnchorValidationHandler(anchor string, pattern interface{}, path string) ValidationAnchorHandler
NewConditionAnchorValidationHandler creates new instance of NoAnchorValidationHandler
func NewExistanceAnchorValidationHandler ¶ added in v0.4.0
func NewExistanceAnchorValidationHandler(anchor string, pattern interface{}, path string) ValidationAnchorHandler
NewExistanceAnchorValidationHandler creates new instance of NoAnchorValidationHandler
func NewNoAnchorValidationHandler ¶ added in v0.4.0
func NewNoAnchorValidationHandler(path string) ValidationAnchorHandler
NewNoAnchorValidationHandler creates new instance of NoAnchorValidationHandler