Skip to content

Commit

Permalink
feat: add update operation (#1088)
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 Mar 9, 2024
1 parent 6c91795 commit 11fe12f
Show file tree
Hide file tree
Showing 25 changed files with 1,399 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .crds/chainsaw.kyverno.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,100 @@ spec:
required:
- duration
type: object
update:
description: Update represents an update operation.
properties:
bindings:
description: Bindings defines additional binding key/values.
items:
description: Binding represents a key/value set
as a binding in an executing test.
properties:
name:
description: Name the name of the binding.
pattern: ^(?:\w+|\(.+\))$
type: string
value:
description: Value value of the binding.
x-kubernetes-preserve-unknown-fields: true
required:
- name
- value
type: object
type: array
cluster:
description: Cluster defines the target cluster (default
cluster will be used if not specified and/or overridden).
type: string
dryRun:
description: DryRun determines whether the file should
be applied in dry run mode.
type: boolean
expect:
description: Expect defines a list of matched checks
to validate the operation outcome.
items:
description: Expectation represents a check to be
applied on the result of an operation with a match
filter to determine if the verification should
be considered.
properties:
check:
description: Check defines the verification
statement.
type: object
x-kubernetes-preserve-unknown-fields: true
match:
description: Match defines the matching statement.
type: object
x-kubernetes-preserve-unknown-fields: true
required:
- check
type: object
type: array
file:
description: File is the path to the referenced file.
This can be a direct path to a file or an expression
that matches multiple files, such as "manifest/*.yaml"
for all YAML files within the "manifest" directory.
type: string
outputs:
description: Outputs defines output bindings.
items:
description: Output represents an output binding
with a match to determine if the binding must
be considered or not.
properties:
match:
description: Match defines the matching statement.
type: object
x-kubernetes-preserve-unknown-fields: true
name:
description: Name the name of the binding.
pattern: ^(?:\w+|\(.+\))$
type: string
value:
description: Value value of the binding.
x-kubernetes-preserve-unknown-fields: true
required:
- name
- value
type: object
type: array
resource:
description: Resource provides a resource to be applied.
type: object
x-kubernetes-embedded-resource: true
x-kubernetes-preserve-unknown-fields: true
template:
description: Template determines whether resources
should be considered for templating.
type: boolean
timeout:
description: Timeout for the operation. Overrides
the global timeout set in the Configuration.
type: string
type: object
wait:
description: Wait determines the resource wait collector
to execute.
Expand Down
92 changes: 92 additions & 0 deletions .crds/chainsaw.kyverno.io_teststeps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,98 @@ spec:
required:
- duration
type: object
update:
description: Update represents an update operation.
properties:
bindings:
description: Bindings defines additional binding key/values.
items:
description: Binding represents a key/value set as a binding
in an executing test.
properties:
name:
description: Name the name of the binding.
pattern: ^(?:\w+|\(.+\))$
type: string
value:
description: Value value of the binding.
x-kubernetes-preserve-unknown-fields: true
required:
- name
- value
type: object
type: array
cluster:
description: Cluster defines the target cluster (default
cluster will be used if not specified and/or overridden).
type: string
dryRun:
description: DryRun determines whether the file should be
applied in dry run mode.
type: boolean
expect:
description: Expect defines a list of matched checks to
validate the operation outcome.
items:
description: Expectation represents a check to be applied
on the result of an operation with a match filter to
determine if the verification should be considered.
properties:
check:
description: Check defines the verification statement.
type: object
x-kubernetes-preserve-unknown-fields: true
match:
description: Match defines the matching statement.
type: object
x-kubernetes-preserve-unknown-fields: true
required:
- check
type: object
type: array
file:
description: File is the path to the referenced file. This
can be a direct path to a file or an expression that matches
multiple files, such as "manifest/*.yaml" for all YAML
files within the "manifest" directory.
type: string
outputs:
description: Outputs defines output bindings.
items:
description: Output represents an output binding with
a match to determine if the binding must be considered
or not.
properties:
match:
description: Match defines the matching statement.
type: object
x-kubernetes-preserve-unknown-fields: true
name:
description: Name the name of the binding.
pattern: ^(?:\w+|\(.+\))$
type: string
value:
description: Value value of the binding.
x-kubernetes-preserve-unknown-fields: true
required:
- name
- value
type: object
type: array
resource:
description: Resource provides a resource to be applied.
type: object
x-kubernetes-embedded-resource: true
x-kubernetes-preserve-unknown-fields: true
template:
description: Template determines whether resources should
be considered for templating.
type: boolean
timeout:
description: Timeout for the operation. Overrides the global
timeout set in the Configuration.
type: string
type: object
wait:
description: Wait determines the resource wait collector to
execute.
Expand Down
138 changes: 138 additions & 0 deletions .schemas/json/test-chainsaw-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -3953,6 +3953,144 @@
}
}
},
"update": {
"description": "Update represents an update operation.",
"type": [
"object",
"null"
],
"properties": {
"bindings": {
"description": "Bindings defines additional binding key/values.",
"type": [
"array",
"null"
],
"items": {
"description": "Binding represents a key/value set as a binding in an executing test.",
"type": [
"object",
"null"
],
"required": [
"name",
"value"
],
"properties": {
"name": {
"description": "Name the name of the binding.",
"type": "string",
"pattern": "^(?:\\w+|\\(.+\\))$"
},
"value": {
"description": "Value value of the binding.",
"x-kubernetes-preserve-unknown-fields": true
}
}
}
},
"cluster": {
"description": "Cluster defines the target cluster (default cluster will be used if not specified and/or overridden).",
"type": [
"string",
"null"
]
},
"dryRun": {
"description": "DryRun determines whether the file should be applied in dry run mode.",
"type": [
"boolean",
"null"
]
},
"expect": {
"description": "Expect defines a list of matched checks to validate the operation outcome.",
"type": [
"array",
"null"
],
"items": {
"description": "Expectation represents a check to be applied on the result of an operation with a match filter to determine if the verification should be considered.",
"type": [
"object",
"null"
],
"required": [
"check"
],
"properties": {
"check": {
"description": "Check defines the verification statement.",
"x-kubernetes-preserve-unknown-fields": true
},
"match": {
"description": "Match defines the matching statement.",
"x-kubernetes-preserve-unknown-fields": true
}
}
}
},
"file": {
"description": "File is the path to the referenced file. This can be a direct path to a file or an expression that matches multiple files, such as \"manifest/*.yaml\" for all YAML files within the \"manifest\" directory.",
"type": [
"string",
"null"
]
},
"outputs": {
"description": "Outputs defines output bindings.",
"type": [
"array",
"null"
],
"items": {
"description": "Output represents an output binding with a match to determine if the binding must be considered or not.",
"type": [
"object",
"null"
],
"required": [
"name",
"value"
],
"properties": {
"match": {
"description": "Match defines the matching statement.",
"x-kubernetes-preserve-unknown-fields": true
},
"name": {
"description": "Name the name of the binding.",
"type": "string",
"pattern": "^(?:\\w+|\\(.+\\))$"
},
"value": {
"description": "Value value of the binding.",
"x-kubernetes-preserve-unknown-fields": true
}
}
}
},
"resource": {
"description": "Resource provides a resource to be applied.",
"x-kubernetes-embedded-resource": true,
"x-kubernetes-preserve-unknown-fields": true
},
"template": {
"description": "Template determines whether resources should be considered for templating.",
"type": [
"boolean",
"null"
]
},
"timeout": {
"description": "Timeout for the operation. Overrides the global timeout set in the Configuration.",
"type": [
"string",
"null"
]
}
}
},
"wait": {
"description": "Wait determines the resource wait collector to execute.",
"type": [
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/v1alpha1/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ type Operation struct {
// +optional
Sleep *Sleep `json:"sleep,omitempty"`

// Update represents an update operation.
// +optional
Update *Update `json:"update,omitempty"`

// Wait determines the resource wait collector to execute.
// +optional
Wait *Wait `json:"wait,omitempty"`
Expand Down
40 changes: 40 additions & 0 deletions pkg/apis/v1alpha1/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Update represents a set of resources that should be updated.
// If a resource does not exist in the cluster it will fail.
type Update struct {
// Timeout for the operation. Overrides the global timeout set in the Configuration.
// +optional
Timeout *metav1.Duration `json:"timeout,omitempty"`

// Bindings defines additional binding key/values.
// +optional
Bindings []Binding `json:"bindings,omitempty"`

// Outputs defines output bindings.
// +optional
Outputs []Output `json:"outputs,omitempty"`

// Cluster defines the target cluster (default cluster will be used if not specified and/or overridden).
// +optional
Cluster string `json:"cluster,omitempty"`

// FileRefOrResource provides a reference to the file containing the resources to be created.
FileRefOrResource `json:",inline"`

// Template determines whether resources should be considered for templating.
// +optional
Template *bool `json:"template,omitempty"`

// DryRun determines whether the file should be applied in dry run mode.
// +optional
DryRun *bool `json:"dryRun,omitempty"`

// Expect defines a list of matched checks to validate the operation outcome.
// +optional
Expect []Expectation `json:"expect,omitempty"`
}
Loading

0 comments on commit 11fe12f

Please sign in to comment.