Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename from to use (cherry-pick #1667) #1668

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .crds/chainsaw.kyverno.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ spec:
- required:
- cleanup
required:
- from
- use
properties:
bindings:
description: Bindings defines additional binding key/values.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions .schemas/json/test-chainsaw-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@
],
"not": {
"required": [
"from"
"use"
],
"anyOf": [
{
Expand Down Expand Up @@ -5311,13 +5311,6 @@
}
}
},
"from": {
"description": "From references a step template.",
"type": [
"string",
"null"
]
},
"name": {
"description": "Name of the step.",
"type": [
Expand Down Expand Up @@ -8897,6 +8890,13 @@
}
}
}
},
"use": {
"description": "Use references a step template.",
"type": [
"string",
"null"
]
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/v1alpha1/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
8 changes: 4 additions & 4 deletions pkg/data/crds/chainsaw.kyverno.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ spec:
- required:
- cleanup
required:
- from
- use
properties:
bindings:
description: Bindings defines additional binding key/values.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions pkg/data/schemas/json/test-chainsaw-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@
],
"not": {
"required": [
"from"
"use"
],
"anyOf": [
{
Expand Down Expand Up @@ -5311,13 +5311,6 @@
}
}
},
"from": {
"description": "From references a step template.",
"type": [
"string",
"null"
]
},
"name": {
"description": "Name of the step.",
"type": [
Expand Down Expand Up @@ -8897,6 +8890,13 @@
}
}
}
},
"use": {
"description": "Use references a step template.",
"type": [
"string",
"null"
]
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/discovery/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
2 changes: 1 addition & 1 deletion testdata/e2e/examples/step-template/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ metadata:
name: quick-start
spec:
steps:
- from: step-template.yaml
- use: step-template.yaml
2 changes: 1 addition & 1 deletion website/docs/reference/apis/chainsaw.v1alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ If a resource doesn't exist yet in the cluster it will fail.</p>
| Field | Type | Required | Inline | Description |
|---|---|---|---|---|
| `name` | `string` | | | <p>Name of the step.</p> |
| `from` | `string` | :white_check_mark: | | <p>From references a step template.</p> |
| `use` | `string` | :white_check_mark: | | <p>Use references a step template.</p> |
| `TestStepSpec` | [`TestStepSpec`](#chainsaw-kyverno-io-v1alpha1-TestStepSpec) | :white_check_mark: | :white_check_mark: | <p>TestStepSpec of the step.</p> |

## TestStepSpec {#chainsaw-kyverno-io-v1alpha1-TestStepSpec}
Expand Down
Loading