Skip to content

Commit

Permalink
feat: add default engine in api (kyverno#485)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Sep 18, 2024
1 parent 5e1c8d5 commit 87fe031
Show file tree
Hide file tree
Showing 14 changed files with 252 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .crds/json.kyverno.io_validatingpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ spec:
spec:
description: Policy spec.
properties:
engine:
description: Engine defines the default engine to use when evaluating
expressions.
enum:
- jp
- cel
type: string
rules:
description: Rules is a list of ValidatingRule instances.
items:
Expand All @@ -57,6 +64,13 @@ spec:
check:
description: Check is the assertion check definition.
x-kubernetes-preserve-unknown-fields: true
engine:
description: Engine defines the default engine to
use when evaluating expressions.
enum:
- jp
- cel
type: string
message:
description: Message is the message associated message.
type: string
Expand All @@ -74,6 +88,13 @@ spec:
check:
description: Check is the assertion check definition.
x-kubernetes-preserve-unknown-fields: true
engine:
description: Engine defines the default engine to
use when evaluating expressions.
enum:
- jp
- cel
type: string
message:
description: Message is the message associated message.
type: string
Expand All @@ -99,6 +120,13 @@ spec:
- name
type: object
type: array
engine:
description: Engine defines the default engine to use when evaluating
expressions.
enum:
- jp
- cel
type: string
exclude:
description: Exclude defines when this policy rule should not
be applied.
Expand Down
32 changes: 32 additions & 0 deletions .schemas/json/_definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -17636,6 +17636,14 @@
"rules"
],
"properties": {
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": "string",
"enum": [
"jp",
"cel"
]
},
"rules": {
"description": "Rules is a list of ValidatingRule instances.",
"type": "array",
Expand Down Expand Up @@ -17665,6 +17673,14 @@
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": "string",
"enum": [
"jp",
"cel"
]
},
"message": {
"description": "Message is the message associated message.",
"type": "string"
Expand All @@ -17686,6 +17702,14 @@
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": "string",
"enum": [
"jp",
"cel"
]
},
"message": {
"description": "Message is the message associated message.",
"type": "string"
Expand Down Expand Up @@ -17716,6 +17740,14 @@
}
}
},
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": "string",
"enum": [
"jp",
"cel"
]
},
"exclude": {
"description": "Exclude defines when this policy rule should not be applied.",
"type": "object",
Expand Down
44 changes: 44 additions & 0 deletions .schemas/json/validatingpolicy-json-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,17 @@
"rules"
],
"properties": {
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"rules": {
"description": "Rules is a list of ValidatingRule instances.",
"type": "array",
Expand Down Expand Up @@ -323,6 +334,17 @@
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"message": {
"description": "Message is the message associated message.",
"type": [
Expand Down Expand Up @@ -353,6 +375,17 @@
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"message": {
"description": "Message is the message associated message.",
"type": [
Expand Down Expand Up @@ -392,6 +425,17 @@
}
}
},
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"exclude": {
"description": "Exclude defines when this policy rule should not be applied.",
"type": [
Expand Down
44 changes: 44 additions & 0 deletions .schemas/json/validatingpolicylist-json-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,17 @@
"rules"
],
"properties": {
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"rules": {
"description": "Rules is a list of ValidatingRule instances.",
"type": "array",
Expand Down Expand Up @@ -346,6 +357,17 @@
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"message": {
"description": "Message is the message associated message.",
"type": [
Expand Down Expand Up @@ -376,6 +398,17 @@
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"message": {
"description": "Message is the message associated message.",
"type": [
Expand Down Expand Up @@ -415,6 +448,17 @@
}
}
},
"engine": {
"description": "Engine defines the default engine to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"exclude": {
"description": "Exclude defines when this policy rule should not be applied.",
"type": [
Expand Down
2 changes: 1 addition & 1 deletion .schemas/openapi/v2/schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .schemas/openapi/v3/apis/json.kyverno.io/v1alpha1.json

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions charts/kyverno-json/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ spec:
spec:
description: Policy spec.
properties:
engine:
description: Engine defines the default engine to use when evaluating
expressions.
enum:
- jp
- cel
type: string
rules:
description: Rules is a list of ValidatingRule instances.
items:
Expand All @@ -66,6 +73,13 @@ spec:
check:
description: Check is the assertion check definition.
x-kubernetes-preserve-unknown-fields: true
engine:
description: Engine defines the default engine to
use when evaluating expressions.
enum:
- jp
- cel
type: string
message:
description: Message is the message associated message.
type: string
Expand All @@ -83,6 +97,13 @@ spec:
check:
description: Check is the assertion check definition.
x-kubernetes-preserve-unknown-fields: true
engine:
description: Engine defines the default engine to
use when evaluating expressions.
enum:
- jp
- cel
type: string
message:
description: Message is the message associated message.
type: string
Expand All @@ -108,6 +129,13 @@ spec:
- name
type: object
type: array
engine:
description: Engine defines the default engine to use when evaluating
expressions.
enum:
- jp
- cel
type: string
exclude:
description: Exclude defines when this policy rule should not
be applied.
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/policy/v1alpha1/assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ type Assertion struct {
// +optional
Message string `json:"message,omitempty"`

// Engine defines the default engine to use when evaluating expressions.
Engine *Engine `json:"engine,omitempty"`

// Check is the assertion check definition.
Check AssertionTree `json:"check"`
}
9 changes: 9 additions & 0 deletions pkg/apis/policy/v1alpha1/engine.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package v1alpha1

// +kubebuilder:validation:Enum:=jp;cel
type Engine string

const (
EngineJP Engine = "jp"
EngineCEL Engine = "cel"
)
3 changes: 3 additions & 0 deletions pkg/apis/policy/v1alpha1/validating_policy_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package v1alpha1

// ValidatingPolicySpec contains the policy spec.
type ValidatingPolicySpec struct {
// Engine defines the default engine to use when evaluating expressions.
Engine *Engine `json:"engine,omitempty"`

// Rules is a list of ValidatingRule instances.
Rules []ValidatingRule `json:"rules"`
}
3 changes: 3 additions & 0 deletions pkg/apis/policy/v1alpha1/validating_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ type ValidatingRule struct {
// +kubebuilder:validation:MaxLength=63
Name string `json:"name"`

// Engine defines the default engine to use when evaluating expressions.
Engine *Engine `json:"engine,omitempty"`

// Context defines variables and data sources that can be used during rule execution.
// +optional
Context []ContextEntry `json:"context,omitempty"`
Expand Down
15 changes: 15 additions & 0 deletions pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 87fe031

Please sign in to comment.