From 047eaf2a2a88ed57891b44b7ca1c45a3013bccd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Fri, 19 Jul 2024 00:15:52 +0200 Subject: [PATCH] chore: rename from to use (#1667) 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_tests.yaml | 8 ++++---- .schemas/json/test-chainsaw-v1alpha1.json | 16 ++++++++-------- pkg/apis/v1alpha1/step.go | 6 +++--- pkg/data/crds/chainsaw.kyverno.io_tests.yaml | 8 ++++---- .../schemas/json/test-chainsaw-v1alpha1.json | 16 ++++++++-------- pkg/discovery/load.go | 6 +++--- .../examples/step-template/chainsaw-test.yaml | 2 +- website/docs/reference/apis/chainsaw.v1alpha1.md | 2 +- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.crds/chainsaw.kyverno.io_tests.yaml b/.crds/chainsaw.kyverno.io_tests.yaml index 93fc70412..4cb93f7aa 100644 --- a/.crds/chainsaw.kyverno.io_tests.yaml +++ b/.crds/chainsaw.kyverno.io_tests.yaml @@ -871,7 +871,7 @@ spec: - required: - cleanup required: - - from + - use properties: bindings: description: Bindings defines additional binding key/values. @@ -3113,9 +3113,6 @@ spec: type: object type: object type: array - from: - description: From references a step template. - type: string name: description: Name of the step. type: string @@ -4585,6 +4582,9 @@ spec: type: object minItems: 1 type: array + use: + description: Use references a step template. + type: string type: object type: array template: diff --git a/.schemas/json/test-chainsaw-v1alpha1.json b/.schemas/json/test-chainsaw-v1alpha1.json index 0e7bd8d74..7ae072b68 100644 --- a/.schemas/json/test-chainsaw-v1alpha1.json +++ b/.schemas/json/test-chainsaw-v1alpha1.json @@ -1684,7 +1684,7 @@ ], "not": { "required": [ - "from" + "use" ], "anyOf": [ { @@ -5311,13 +5311,6 @@ } } }, - "from": { - "description": "From references a step template.", - "type": [ - "string", - "null" - ] - }, "name": { "description": "Name of the step.", "type": [ @@ -8897,6 +8890,13 @@ } } } + }, + "use": { + "description": "Use references a step template.", + "type": [ + "string", + "null" + ] } } } diff --git a/pkg/apis/v1alpha1/step.go b/pkg/apis/v1alpha1/step.go index 6dac4e933..0b3711327 100644 --- a/pkg/apis/v1alpha1/step.go +++ b/pkg/apis/v1alpha1/step.go @@ -46,14 +46,14 @@ type StepTemplateSpec struct { } // TestStep contains the test step definition used in a test spec. -// +kubebuilder:not:={required:{from},anyOf:{{required:{try}},{required:{catch}},{required:{finally}},{required:{cleanup}}}} +// +kubebuilder:not:={required:{use},anyOf:{{required:{try}},{required:{catch}},{required:{finally}},{required:{cleanup}}}} type TestStep struct { // Name of the step. // +optional Name string `json:"name,omitempty"` - // From references a step template. - From string `json:"from,omitempty"` + // Use references a step template. + Use string `json:"use,omitempty"` // TestStepSpec of the step. TestStepSpec `json:",inline"` diff --git a/pkg/data/crds/chainsaw.kyverno.io_tests.yaml b/pkg/data/crds/chainsaw.kyverno.io_tests.yaml index 93fc70412..4cb93f7aa 100644 --- a/pkg/data/crds/chainsaw.kyverno.io_tests.yaml +++ b/pkg/data/crds/chainsaw.kyverno.io_tests.yaml @@ -871,7 +871,7 @@ spec: - required: - cleanup required: - - from + - use properties: bindings: description: Bindings defines additional binding key/values. @@ -3113,9 +3113,6 @@ spec: type: object type: object type: array - from: - description: From references a step template. - type: string name: description: Name of the step. type: string @@ -4585,6 +4582,9 @@ spec: type: object minItems: 1 type: array + use: + description: Use references a step template. + type: string type: object type: array template: diff --git a/pkg/data/schemas/json/test-chainsaw-v1alpha1.json b/pkg/data/schemas/json/test-chainsaw-v1alpha1.json index 0e7bd8d74..7ae072b68 100644 --- a/pkg/data/schemas/json/test-chainsaw-v1alpha1.json +++ b/pkg/data/schemas/json/test-chainsaw-v1alpha1.json @@ -1684,7 +1684,7 @@ ], "not": { "required": [ - "from" + "use" ], "anyOf": [ { @@ -5311,13 +5311,6 @@ } } }, - "from": { - "description": "From references a step template.", - "type": [ - "string", - "null" - ] - }, "name": { "description": "Name of the step.", "type": [ @@ -8897,6 +8890,13 @@ } } } + }, + "use": { + "description": "Use references a step template.", + "type": [ + "string", + "null" + ] } } } diff --git a/pkg/discovery/load.go b/pkg/discovery/load.go index 707ea3e70..ddb528241 100644 --- a/pkg/discovery/load.go +++ b/pkg/discovery/load.go @@ -58,15 +58,15 @@ func LoadTest(fileName string, path string, remarshal bool) ([]Test, error) { for _, apiTest := range apiTests { for step := range apiTest.Spec.Steps { step := &apiTest.Spec.Steps[step] - if step.From != "" { - steptpl, err := steptemplate.Load(filepath.Join(path, step.From), remarshal) + if step.Use != "" { + steptpl, err := steptemplate.Load(filepath.Join(path, step.Use), remarshal) if err != nil { return nil, err } if len(steptpl) != 1 { return nil, errors.New("step template not found or multiple templates exist") } - step.From = "" + step.Use = "" step.Bindings = append(step.Bindings, steptpl[0].Spec.Bindings...) step.Try = append(step.Try, steptpl[0].Spec.Try...) step.Catch = append(step.Catch, steptpl[0].Spec.Catch...) diff --git a/testdata/e2e/examples/step-template/chainsaw-test.yaml b/testdata/e2e/examples/step-template/chainsaw-test.yaml index 224718eec..56d915512 100644 --- a/testdata/e2e/examples/step-template/chainsaw-test.yaml +++ b/testdata/e2e/examples/step-template/chainsaw-test.yaml @@ -5,4 +5,4 @@ metadata: name: quick-start spec: steps: - - from: step-template.yaml + - use: step-template.yaml diff --git a/website/docs/reference/apis/chainsaw.v1alpha1.md b/website/docs/reference/apis/chainsaw.v1alpha1.md index 829b27eba..7e457b11c 100644 --- a/website/docs/reference/apis/chainsaw.v1alpha1.md +++ b/website/docs/reference/apis/chainsaw.v1alpha1.md @@ -863,7 +863,7 @@ If a resource doesn't exist yet in the cluster it will fail.

| Field | Type | Required | Inline | Description | |---|---|---|---|---| | `name` | `string` | | |

Name of the step.

| -| `from` | `string` | :white_check_mark: | |

From references a step template.

| +| `use` | `string` | :white_check_mark: | |

Use references a step template.

| | `TestStepSpec` | [`TestStepSpec`](#chainsaw-kyverno-io-v1alpha1-TestStepSpec) | :white_check_mark: | :white_check_mark: |

TestStepSpec of the step.

| ## TestStepSpec {#chainsaw-kyverno-io-v1alpha1-TestStepSpec}