mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-07 00:17:13 +00:00
* initial commit * background policy validation * correct message * skip non-background policy process for add/update * add Generate Request CR * generate Request Generator Initial * test generate request CR generation * initial commit gr generator * generate controller initial framework * add crd for generate request * gr cleanup controller initial commit * cleanup controller initial * generate mid-commit * generate rule processing * create PV on generate error * embed resource type * testing phase 1- generate resources with variable substitution * fix tests * comment broken test #586 * add printer column for state * return if existing resource for clone * set resync time to 2 mins & remove resource version check in update handler for gr * generate events for reporting * fix logs * initial commit * fix trailing quote in patch * remove comments * initial condition (equal & notequal) * initial support for conditions * initial support fo conditions in generate * support precondition checks * cleanup * re-evaluate GR on namespace update using dynamic informers * add status for generated resources * display loaded variable SA * support delete cleanup of generate request main resources * fix log * remove namespace from SA username * support multiple variables per statement for scalar values * fix fail variables * add check for userInfo * validation checks for conditions * update policy * refactor logs * code review * add openapispec for clusterpolicy preconditions * Update documentation * CR fixes * documentation * CR fixes * update variable * fix logs * update policy * pre-defined variables (serviceAccountName & serviceAccountNamespace) * update test
30 lines
1 KiB
Go
30 lines
1 KiB
Go
package operator
|
|
|
|
import (
|
|
"github.com/golang/glog"
|
|
kyverno "github.com/nirmata/kyverno/pkg/api/kyverno/v1"
|
|
"github.com/nirmata/kyverno/pkg/engine/context"
|
|
)
|
|
|
|
type OperatorHandler interface {
|
|
Evaluate(key, value interface{}) bool
|
|
validateValuewithBoolPattern(key bool, value interface{}) bool
|
|
validateValuewithIntPattern(key int64, value interface{}) bool
|
|
validateValuewithFloatPattern(key float64, value interface{}) bool
|
|
validateValueWithMapPattern(key map[string]interface{}, value interface{}) bool
|
|
validateValueWithSlicePattern(key []interface{}, value interface{}) bool
|
|
}
|
|
|
|
type VariableSubstitutionHandler = func(ctx context.EvalInterface, pattern interface{}) interface{}
|
|
|
|
func CreateOperatorHandler(ctx context.EvalInterface, op kyverno.ConditionOperator, subHandler VariableSubstitutionHandler) OperatorHandler {
|
|
switch op {
|
|
case kyverno.Equal:
|
|
return NewEqualHandler(ctx, subHandler)
|
|
case kyverno.NotEqual:
|
|
return NewNotEqualHandler(ctx, subHandler)
|
|
default:
|
|
glog.Errorf("unsupported operator: %s", string(op))
|
|
}
|
|
return nil
|
|
}
|