Skip to content

Commit

Permalink
feat: add compiler at the step api level (#2043)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly authored Sep 30, 2024
1 parent 2a11382 commit e876efe
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .crds/chainsaw.kyverno.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2556,6 +2556,13 @@ spec:
description: Clusters holds a registry to clusters to support
multi-cluster tests.
type: object
compiler:
description: Compiler defines the default compiler to use when
evaluating expressions.
enum:
- jp
- cel
type: string
deletionPropagationPolicy:
description: |-
DeletionPropagationPolicy decides if a deletion will propagate to the dependents of
Expand Down
11 changes: 11 additions & 0 deletions .schemas/json/test-chainsaw-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4499,6 +4499,17 @@
"additionalProperties": false
}
},
"compiler": {
"description": "Compiler defines the default compiler to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"deletionPropagationPolicy": {
"description": "DeletionPropagationPolicy decides if a deletion will propagate to the dependents of\nthe object, and how the garbage collector will handle the propagation.\nOverrides the deletion propagation policy set in both the Configuration and the Test.",
"type": [
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/v1alpha1/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ type TestStepSpec struct {
// +optional
Template *bool `json:"template,omitempty"`

// Compiler defines the default compiler to use when evaluating expressions.
// +optional
Compiler *Compiler `json:"compiler,omitempty"`

// Bindings defines additional binding key/values.
// +optional
Bindings []Binding `json:"bindings,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/v1alpha1/zz_generated.deepcopy.go

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

7 changes: 7 additions & 0 deletions pkg/data/crds/chainsaw.kyverno.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2556,6 +2556,13 @@ spec:
description: Clusters holds a registry to clusters to support
multi-cluster tests.
type: object
compiler:
description: Compiler defines the default compiler to use when
evaluating expressions.
enum:
- jp
- cel
type: string
deletionPropagationPolicy:
description: |-
DeletionPropagationPolicy decides if a deletion will propagate to the dependents of
Expand Down
11 changes: 11 additions & 0 deletions pkg/data/schemas/json/test-chainsaw-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4499,6 +4499,17 @@
"additionalProperties": false
}
},
"compiler": {
"description": "Compiler defines the default compiler to use when evaluating expressions.",
"type": [
"string",
"null"
],
"enum": [
"jp",
"cel"
]
},
"deletionPropagationPolicy": {
"description": "DeletionPropagationPolicy decides if a deletion will propagate to the dependents of\nthe object, and how the garbage collector will handle the propagation.\nOverrides the deletion propagation policy set in both the Configuration and the Test.",
"type": [
Expand Down
3 changes: 3 additions & 0 deletions pkg/runner/processors/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func (p *stepProcessor) Run(ctx context.Context, namespacer namespacer.Namespace
p.report.Add(report)
}()
logger := logging.FromContext(ctx)
if p.step.Compiler != nil {
tc = tc.WithDefaultCompiler(string(*p.step.Compiler))
}
tc, _, err := setupContextData(ctx, tc, contextData{
basePath: p.basePath,
bindings: p.step.Bindings,
Expand Down
1 change: 1 addition & 0 deletions website/docs/reference/apis/chainsaw.v1alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ If a resource doesn't exist yet in the cluster it will fail.</p>
| `clusters` | [`Clusters`](#chainsaw-kyverno-io-v1alpha1-Clusters) | | | <p>Clusters holds a registry to clusters to support multi-cluster tests.</p> |
| `skipDelete` | `bool` | | | <p>SkipDelete determines whether the resources created by the step should be deleted after the test step is executed.</p> |
| `template` | `bool` | | | <p>Template determines whether resources should be considered for templating.</p> |
| `compiler` | `policy/v1alpha1.Compiler` | | | <p>Compiler defines the default compiler to use when evaluating expressions.</p> |
| `bindings` | [`[]Binding`](#chainsaw-kyverno-io-v1alpha1-Binding) | | | <p>Bindings defines additional binding key/values.</p> |
| `try` | [`[]Operation`](#chainsaw-kyverno-io-v1alpha1-Operation) | | | <p>Try defines what the step will try to execute.</p> |
| `catch` | [`[]CatchFinally`](#chainsaw-kyverno-io-v1alpha1-CatchFinally) | | | <p>Catch defines what the step will execute when an error happens.</p> |
Expand Down

0 comments on commit e876efe

Please sign in to comment.