From 9fddcdbb461bc10032ad82804147e8a1e19c85fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?=
Date: Mon, 30 Sep 2024 12:19:53 +0200
Subject: [PATCH] feat: add default compiler at the operation api level
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Charles-Edouard Brétéché
---
.crds/chainsaw.kyverno.io_configurations.yaml | 14 +++++
.crds/chainsaw.kyverno.io_steptemplates.yaml | 28 ++++++++++
.crds/chainsaw.kyverno.io_tests.yaml | 35 ++++++++++++
.../json/configuration-chainsaw-v1alpha1.json | 11 ++++
.../json/configuration-chainsaw-v1alpha2.json | 11 ++++
.../json/steptemplate-chainsaw-v1alpha1.json | 44 +++++++++++++++
.schemas/json/test-chainsaw-v1alpha1.json | 55 +++++++++++++++++++
pkg/apis/v1alpha1/catch_finally.go | 4 ++
pkg/apis/v1alpha1/operation.go | 4 ++
pkg/apis/v1alpha1/zz_generated.deepcopy.go | 10 ++++
.../chainsaw.kyverno.io_configurations.yaml | 14 +++++
.../chainsaw.kyverno.io_steptemplates.yaml | 28 ++++++++++
pkg/data/crds/chainsaw.kyverno.io_tests.yaml | 35 ++++++++++++
.../json/configuration-chainsaw-v1alpha1.json | 11 ++++
.../json/configuration-chainsaw-v1alpha2.json | 11 ++++
.../json/steptemplate-chainsaw-v1alpha1.json | 44 +++++++++++++++
.../schemas/json/test-chainsaw-v1alpha1.json | 55 +++++++++++++++++++
pkg/runner/processors/step.go | 48 ++++++++++------
.../docs/reference/apis/chainsaw.v1alpha1.md | 2 +
19 files changed, 448 insertions(+), 16 deletions(-)
diff --git a/.crds/chainsaw.kyverno.io_configurations.yaml b/.crds/chainsaw.kyverno.io_configurations.yaml
index 0fe679199..13d5e94fa 100644
--- a/.crds/chainsaw.kyverno.io_configurations.yaml
+++ b/.crds/chainsaw.kyverno.io_configurations.yaml
@@ -197,6 +197,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -1210,6 +1217,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use
+ when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
diff --git a/.crds/chainsaw.kyverno.io_steptemplates.yaml b/.crds/chainsaw.kyverno.io_steptemplates.yaml
index cd41a4967..6ba6573b9 100644
--- a/.crds/chainsaw.kyverno.io_steptemplates.yaml
+++ b/.crds/chainsaw.kyverno.io_steptemplates.yaml
@@ -220,6 +220,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -979,6 +986,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -1738,6 +1752,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -2708,6 +2729,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
continueOnError:
description: |-
ContinueOnError determines whether a test should continue or not in case the operation was not successful.
diff --git a/.crds/chainsaw.kyverno.io_tests.yaml b/.crds/chainsaw.kyverno.io_tests.yaml
index 6b58bf5c7..d65a56e60 100644
--- a/.crds/chainsaw.kyverno.io_tests.yaml
+++ b/.crds/chainsaw.kyverno.io_tests.yaml
@@ -221,6 +221,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -1137,6 +1144,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to
+ use when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -1916,6 +1930,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to
+ use when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -2737,6 +2758,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to
+ use when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -3767,6 +3795,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to
+ use when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
continueOnError:
description: |-
ContinueOnError determines whether a test should continue or not in case the operation was not successful.
diff --git a/.schemas/json/configuration-chainsaw-v1alpha1.json b/.schemas/json/configuration-chainsaw-v1alpha1.json
index dc8a3361a..52e1a1818 100644
--- a/.schemas/json/configuration-chainsaw-v1alpha1.json
+++ b/.schemas/json/configuration-chainsaw-v1alpha1.json
@@ -607,6 +607,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
diff --git a/.schemas/json/configuration-chainsaw-v1alpha2.json b/.schemas/json/configuration-chainsaw-v1alpha2.json
index 530e2ac81..de0e25ab8 100644
--- a/.schemas/json/configuration-chainsaw-v1alpha2.json
+++ b/.schemas/json/configuration-chainsaw-v1alpha2.json
@@ -735,6 +735,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
diff --git a/.schemas/json/steptemplate-chainsaw-v1alpha1.json b/.schemas/json/steptemplate-chainsaw-v1alpha1.json
index 4f3eb3d16..aa9815a95 100644
--- a/.schemas/json/steptemplate-chainsaw-v1alpha1.json
+++ b/.schemas/json/steptemplate-chainsaw-v1alpha1.json
@@ -651,6 +651,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -1925,6 +1936,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -3199,6 +3221,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -5135,6 +5168,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"continueOnError": {
"description": "ContinueOnError determines whether a test should continue or not in case the operation was not successful.\nEven if the test continues executing, it will still be reported as failed.",
"type": [
diff --git a/.schemas/json/test-chainsaw-v1alpha1.json b/.schemas/json/test-chainsaw-v1alpha1.json
index da73a9fa9..8e58bcc53 100644
--- a/.schemas/json/test-chainsaw-v1alpha1.json
+++ b/.schemas/json/test-chainsaw-v1alpha1.json
@@ -651,6 +651,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -2193,6 +2204,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -3467,6 +3489,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -4809,6 +4842,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -6821,6 +6865,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"continueOnError": {
"description": "ContinueOnError determines whether a test should continue or not in case the operation was not successful.\nEven if the test continues executing, it will still be reported as failed.",
"type": [
diff --git a/pkg/apis/v1alpha1/catch_finally.go b/pkg/apis/v1alpha1/catch_finally.go
index 1c0960a3c..ef0d71992 100644
--- a/pkg/apis/v1alpha1/catch_finally.go
+++ b/pkg/apis/v1alpha1/catch_finally.go
@@ -15,6 +15,10 @@ type CatchFinally struct {
// +optional
Description string `json:"description,omitempty"`
+ // Compiler defines the default compiler to use when evaluating expressions.
+ // +optional
+ Compiler *Compiler `json:"compiler,omitempty"`
+
// PodLogs determines the pod logs collector to execute.
// +optional
PodLogs *PodLogs `json:"podLogs,omitempty"`
diff --git a/pkg/apis/v1alpha1/operation.go b/pkg/apis/v1alpha1/operation.go
index 35d472dd5..4fac1ba77 100644
--- a/pkg/apis/v1alpha1/operation.go
+++ b/pkg/apis/v1alpha1/operation.go
@@ -10,6 +10,10 @@ type OperationBase struct {
// Even if the test continues executing, it will still be reported as failed.
// +optional
ContinueOnError *bool `json:"continueOnError,omitempty"`
+
+ // Compiler defines the default compiler to use when evaluating expressions.
+ // +optional
+ Compiler *Compiler `json:"compiler,omitempty"`
}
// Operation defines a single operation, only one action is permitted for a given operation.
diff --git a/pkg/apis/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/v1alpha1/zz_generated.deepcopy.go
index 46949eb2b..74f0afeec 100644
--- a/pkg/apis/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/v1alpha1/zz_generated.deepcopy.go
@@ -400,6 +400,11 @@ func (in *Binding) DeepCopy() *Binding {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CatchFinally) DeepCopyInto(out *CatchFinally) {
*out = *in
+ if in.Compiler != nil {
+ in, out := &in.Compiler, &out.Compiler
+ *out = new(policyv1alpha1.Compiler)
+ **out = **in
+ }
if in.PodLogs != nil {
in, out := &in.PodLogs, &out.PodLogs
*out = new(PodLogs)
@@ -983,6 +988,11 @@ func (in *OperationBase) DeepCopyInto(out *OperationBase) {
*out = new(bool)
**out = **in
}
+ if in.Compiler != nil {
+ in, out := &in.Compiler, &out.Compiler
+ *out = new(policyv1alpha1.Compiler)
+ **out = **in
+ }
return
}
diff --git a/pkg/data/crds/chainsaw.kyverno.io_configurations.yaml b/pkg/data/crds/chainsaw.kyverno.io_configurations.yaml
index 0fe679199..13d5e94fa 100644
--- a/pkg/data/crds/chainsaw.kyverno.io_configurations.yaml
+++ b/pkg/data/crds/chainsaw.kyverno.io_configurations.yaml
@@ -197,6 +197,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -1210,6 +1217,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use
+ when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
diff --git a/pkg/data/crds/chainsaw.kyverno.io_steptemplates.yaml b/pkg/data/crds/chainsaw.kyverno.io_steptemplates.yaml
index cd41a4967..6ba6573b9 100644
--- a/pkg/data/crds/chainsaw.kyverno.io_steptemplates.yaml
+++ b/pkg/data/crds/chainsaw.kyverno.io_steptemplates.yaml
@@ -220,6 +220,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -979,6 +986,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -1738,6 +1752,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -2708,6 +2729,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
continueOnError:
description: |-
ContinueOnError determines whether a test should continue or not in case the operation was not successful.
diff --git a/pkg/data/crds/chainsaw.kyverno.io_tests.yaml b/pkg/data/crds/chainsaw.kyverno.io_tests.yaml
index 6b58bf5c7..d65a56e60 100644
--- a/pkg/data/crds/chainsaw.kyverno.io_tests.yaml
+++ b/pkg/data/crds/chainsaw.kyverno.io_tests.yaml
@@ -221,6 +221,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to use when
+ evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -1137,6 +1144,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to
+ use when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -1916,6 +1930,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to
+ use when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -2737,6 +2758,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to
+ use when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
delete:
description: Delete represents a deletion operation.
not:
@@ -3767,6 +3795,13 @@ spec:
required:
- entrypoint
type: object
+ compiler:
+ description: Compiler defines the default compiler to
+ use when evaluating expressions.
+ enum:
+ - jp
+ - cel
+ type: string
continueOnError:
description: |-
ContinueOnError determines whether a test should continue or not in case the operation was not successful.
diff --git a/pkg/data/schemas/json/configuration-chainsaw-v1alpha1.json b/pkg/data/schemas/json/configuration-chainsaw-v1alpha1.json
index dc8a3361a..52e1a1818 100644
--- a/pkg/data/schemas/json/configuration-chainsaw-v1alpha1.json
+++ b/pkg/data/schemas/json/configuration-chainsaw-v1alpha1.json
@@ -607,6 +607,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
diff --git a/pkg/data/schemas/json/configuration-chainsaw-v1alpha2.json b/pkg/data/schemas/json/configuration-chainsaw-v1alpha2.json
index 530e2ac81..de0e25ab8 100644
--- a/pkg/data/schemas/json/configuration-chainsaw-v1alpha2.json
+++ b/pkg/data/schemas/json/configuration-chainsaw-v1alpha2.json
@@ -735,6 +735,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
diff --git a/pkg/data/schemas/json/steptemplate-chainsaw-v1alpha1.json b/pkg/data/schemas/json/steptemplate-chainsaw-v1alpha1.json
index 4f3eb3d16..aa9815a95 100644
--- a/pkg/data/schemas/json/steptemplate-chainsaw-v1alpha1.json
+++ b/pkg/data/schemas/json/steptemplate-chainsaw-v1alpha1.json
@@ -651,6 +651,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -1925,6 +1936,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -3199,6 +3221,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -5135,6 +5168,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"continueOnError": {
"description": "ContinueOnError determines whether a test should continue or not in case the operation was not successful.\nEven if the test continues executing, it will still be reported as failed.",
"type": [
diff --git a/pkg/data/schemas/json/test-chainsaw-v1alpha1.json b/pkg/data/schemas/json/test-chainsaw-v1alpha1.json
index da73a9fa9..8e58bcc53 100644
--- a/pkg/data/schemas/json/test-chainsaw-v1alpha1.json
+++ b/pkg/data/schemas/json/test-chainsaw-v1alpha1.json
@@ -651,6 +651,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -2193,6 +2204,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -3467,6 +3489,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -4809,6 +4842,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"delete": {
"description": "Delete represents a deletion operation.",
"type": [
@@ -6821,6 +6865,17 @@
},
"additionalProperties": false
},
+ "compiler": {
+ "description": "Compiler defines the default compiler to use when evaluating expressions.",
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "jp",
+ "cel"
+ ]
+ },
"continueOnError": {
"description": "ContinueOnError determines whether a test should continue or not in case the operation was not successful.\nEven if the test continues executing, it will still be reported as failed.",
"type": [
diff --git a/pkg/runner/processors/step.go b/pkg/runner/processors/step.go
index 38abcd7e3..1d638ee63 100644
--- a/pkg/runner/processors/step.go
+++ b/pkg/runner/processors/step.go
@@ -141,13 +141,17 @@ func (p *stepProcessor) Run(ctx context.Context, namespacer namespacer.Namespace
}
}
for i, operation := range p.step.Cleanup {
- operations, err := p.finallyOperation(tc.Compilers(), i, namespacer, tc.Bindings(), operation)
+ operationTc := tc
+ if operation.Compiler != nil {
+ operationTc = operationTc.WithDefaultCompiler(string(*operation.Compiler))
+ }
+ operations, err := p.finallyOperation(operationTc.Compilers(), i, namespacer, operationTc.Bindings(), operation)
if err != nil {
logger.Log(logging.Cleanup, logging.ErrorStatus, color.BoldRed, logging.ErrSection(err))
failer.Fail(ctx)
}
for _, operation := range operations {
- _, err := operation.execute(ctx, tc, report)
+ _, err := operation.execute(ctx, operationTc, report)
if err != nil {
failer.Fail(ctx)
}
@@ -162,13 +166,17 @@ func (p *stepProcessor) Run(ctx context.Context, namespacer namespacer.Namespace
logger.Log(logging.Finally, logging.EndStatus, color.BoldFgCyan)
}()
for i, operation := range p.step.Finally {
- operations, err := p.finallyOperation(tc.Compilers(), i, namespacer, tc.Bindings(), operation)
+ operationTc := tc
+ if operation.Compiler != nil {
+ operationTc = operationTc.WithDefaultCompiler(string(*operation.Compiler))
+ }
+ operations, err := p.finallyOperation(operationTc.Compilers(), i, namespacer, operationTc.Bindings(), operation)
if err != nil {
logger.Log(logging.Finally, logging.ErrorStatus, color.BoldRed, logging.ErrSection(err))
failer.Fail(ctx)
}
for _, operation := range operations {
- _, err := operation.execute(ctx, tc, report)
+ _, err := operation.execute(ctx, operationTc, report)
if err != nil {
failer.Fail(ctx)
}
@@ -184,13 +192,17 @@ func (p *stepProcessor) Run(ctx context.Context, namespacer namespacer.Namespace
logger.Log(logging.Catch, logging.EndStatus, color.BoldFgCyan)
}()
for i, operation := range p.catch {
- operations, err := p.catchOperation(tc.Compilers(), i, namespacer, tc.Bindings(), operation)
+ operationTc := tc
+ if operation.Compiler != nil {
+ operationTc = operationTc.WithDefaultCompiler(string(*operation.Compiler))
+ }
+ operations, err := p.catchOperation(operationTc.Compilers(), i, namespacer, operationTc.Bindings(), operation)
if err != nil {
logger.Log(logging.Catch, logging.ErrorStatus, color.BoldRed, logging.ErrSection(err))
failer.Fail(ctx)
}
for _, operation := range operations {
- _, err := operation.execute(ctx, tc, report)
+ _, err := operation.execute(ctx, operationTc, report)
if err != nil {
failer.Fail(ctx)
}
@@ -204,14 +216,18 @@ func (p *stepProcessor) Run(ctx context.Context, namespacer namespacer.Namespace
logger.Log(logging.Try, logging.EndStatus, color.BoldFgCyan)
}()
for i, operation := range p.step.Try {
+ operationTc := tc
+ if operation.Compiler != nil {
+ operationTc = operationTc.WithDefaultCompiler(string(*operation.Compiler))
+ }
continueOnError := operation.ContinueOnError != nil && *operation.ContinueOnError
- operations, err := p.tryOperation(tc.Compilers(), i, namespacer, tc.Bindings(), operation, cleaner)
+ operations, err := p.tryOperation(operationTc.Compilers(), i, namespacer, operationTc.Bindings(), operation, cleaner)
if err != nil {
logger.Log(logging.Try, logging.ErrorStatus, color.BoldRed, logging.ErrSection(err))
failer.FailNow(ctx)
}
for _, operation := range operations {
- outputs, err := operation.execute(ctx, tc, report)
+ outputs, err := operation.execute(ctx, operationTc, report)
if err != nil {
if continueOnError {
failer.Fail(ctx)
@@ -483,7 +499,7 @@ func (p *stepProcessor) assertOperation(compilers compilers.Compilers, id int, n
return ops, nil
}
-func (p *stepProcessor) commandOperation(compilers compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Command) operation {
+func (p *stepProcessor) commandOperation(_ compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Command) operation {
ns := ""
if namespacer != nil {
ns = namespacer.GetNamespace()
@@ -626,7 +642,7 @@ func (p *stepProcessor) deleteOperation(compilers compilers.Compilers, id int, n
return ops, nil
}
-func (p *stepProcessor) describeOperation(compilers compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Describe) operation {
+func (p *stepProcessor) describeOperation(_ compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Describe) operation {
ns := ""
if namespacer != nil {
ns = namespacer.GetNamespace()
@@ -712,7 +728,7 @@ func (p *stepProcessor) errorOperation(compilers compilers.Compilers, id int, na
return ops, nil
}
-func (p *stepProcessor) getOperation(compilers compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Get) operation {
+func (p *stepProcessor) getOperation(_ compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Get) operation {
ns := ""
if namespacer != nil {
ns = namespacer.GetNamespace()
@@ -756,7 +772,7 @@ func (p *stepProcessor) getOperation(compilers compilers.Compilers, id int, name
)
}
-func (p *stepProcessor) logsOperation(compilers compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.PodLogs) operation {
+func (p *stepProcessor) logsOperation(_ compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.PodLogs) operation {
ns := ""
if namespacer != nil {
ns = namespacer.GetNamespace()
@@ -848,7 +864,7 @@ func (p *stepProcessor) patchOperation(compilers compilers.Compilers, id int, na
return ops, nil
}
-func (p *stepProcessor) proxyOperation(compilers compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Proxy) operation {
+func (p *stepProcessor) proxyOperation(_ compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Proxy) operation {
ns := ""
if namespacer != nil {
ns = namespacer.GetNamespace()
@@ -892,7 +908,7 @@ func (p *stepProcessor) proxyOperation(compilers compilers.Compilers, id int, na
)
}
-func (p *stepProcessor) scriptOperation(compilers compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Script) operation {
+func (p *stepProcessor) scriptOperation(_ compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Script) operation {
ns := ""
if namespacer != nil {
ns = namespacer.GetNamespace()
@@ -927,7 +943,7 @@ func (p *stepProcessor) scriptOperation(compilers compilers.Compilers, id int, n
)
}
-func (p *stepProcessor) sleepOperation(compilers compilers.Compilers, id int, op v1alpha1.Sleep) operation {
+func (p *stepProcessor) sleepOperation(_ compilers.Compilers, id int, op v1alpha1.Sleep) operation {
return newOperation(
OperationInfo{
Id: id,
@@ -987,7 +1003,7 @@ func (p *stepProcessor) updateOperation(compilers compilers.Compilers, id int, n
return ops, nil
}
-func (p *stepProcessor) waitOperation(compilers compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Wait) operation {
+func (p *stepProcessor) waitOperation(_ compilers.Compilers, id int, namespacer namespacer.Namespacer, op v1alpha1.Wait) operation {
ns := ""
if namespacer != nil {
ns = namespacer.GetNamespace()
diff --git a/website/docs/reference/apis/chainsaw.v1alpha1.md b/website/docs/reference/apis/chainsaw.v1alpha1.md
index a64ba0162..29490e05a 100644
--- a/website/docs/reference/apis/chainsaw.v1alpha1.md
+++ b/website/docs/reference/apis/chainsaw.v1alpha1.md
@@ -362,6 +362,7 @@ during the testing process.
| Field | Type | Required | Inline | Description |
|---|---|---|---|---|
| `description` | `string` | | | Description contains a description of the operation.
|
+| `compiler` | `policy/v1alpha1.Compiler` | | | Compiler defines the default compiler to use when evaluating expressions.
|
| `podLogs` | [`PodLogs`](#chainsaw-kyverno-io-v1alpha1-PodLogs) | | | PodLogs determines the pod logs collector to execute.
|
| `events` | [`Events`](#chainsaw-kyverno-io-v1alpha1-Events) | | | Events determines the events collector to execute.
|
| `describe` | [`Describe`](#chainsaw-kyverno-io-v1alpha1-Describe) | | | Describe determines the resource describe collector to execute.
|
@@ -721,6 +722,7 @@ For multiple objects use labels.
|---|---|---|---|---|
| `description` | `string` | | | Description contains a description of the operation.
|
| `continueOnError` | `bool` | | | ContinueOnError determines whether a test should continue or not in case the operation was not successful. Even if the test continues executing, it will still be reported as failed.
|
+| `compiler` | `policy/v1alpha1.Compiler` | | | Compiler defines the default compiler to use when evaluating expressions.
|
## Output {#chainsaw-kyverno-io-v1alpha1-Output}