Skip to content

Commit

Permalink
feat:support default value into apiCall context variables (kyverno#10594
Browse files Browse the repository at this point in the history
)

* initial changes

Signed-off-by: sivasathyaseeelan <[email protected]>

* test changes

Signed-off-by: sivasathyaseeelan <[email protected]>

* logical changes

Signed-off-by: sivasathyaseeelan <[email protected]>

* added Check for default in transformAndStore

Signed-off-by: sivasathyaseeelan <[email protected]>

* codegen applied

Signed-off-by: sivasathyaseeelan <[email protected]>

* considered an edge case

Signed-off-by: sivasathyaseeelan <[email protected]>

* fix: remove error when jsondata and default is nil

Signed-off-by: Vishal Choudhary <[email protected]>

* codegen done

Signed-off-by: sivasathyaseeelan <[email protected]>

---------

Signed-off-by: sivasathyaseeelan <[email protected]>
Signed-off-by: Vishal Choudhary <[email protected]>
Co-authored-by: Vishal Choudhary <[email protected]>
Co-authored-by: shuting <[email protected]>
  • Loading branch information
3 people authored Sep 5, 2024
1 parent b78c501 commit cc966bf
Show file tree
Hide file tree
Showing 25 changed files with 1,044 additions and 3 deletions.
5 changes: 5 additions & 0 deletions api/kyverno/v1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ type APICall struct {
type ContextAPICall struct {
APICall `json:",inline" yaml:",inline"`

// Default is an optional arbitrary JSON object that the context may take if the apiCall
// returns error
// +optional
Default *apiextv1.JSON `json:"default,omitempty" yaml:"default,omitempty"`

// JMESPath is an optional JSON Match Expression that can be used to
// transform the JSON response returned from the server. For example
// a JMESPath of "items | length(@)" applied to the API server response
Expand Down
5 changes: 5 additions & 0 deletions api/kyverno/v1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ spec:
- value
type: object
type: array
default:
description: |-
Default is an optional arbitrary JSON object that the context may take if the apiCall
returns error
x-kubernetes-preserve-unknown-fields: true
jmesPath:
description: |-
JMESPath is an optional JSON Match Expression that can be used to
Expand Down Expand Up @@ -1455,6 +1460,11 @@ spec:
- value
type: object
type: array
default:
description: |-
Default is an optional arbitrary JSON object that the context may take if the apiCall
returns error
x-kubernetes-preserve-unknown-fields: true
jmesPath:
description: |-
JMESPath is an optional JSON Match Expression that can be used to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ spec:
- value
type: object
type: array
default:
description: |-
Default is an optional arbitrary JSON object that the context may take if the apiCall
returns error
x-kubernetes-preserve-unknown-fields: true
jmesPath:
description: |-
JMESPath is an optional JSON Match Expression that can be used to
Expand Down Expand Up @@ -1455,6 +1460,11 @@ spec:
- value
type: object
type: array
default:
description: |-
Default is an optional arbitrary JSON object that the context may take if the apiCall
returns error
x-kubernetes-preserve-unknown-fields: true
jmesPath:
description: |-
JMESPath is an optional JSON Match Expression that can be used to
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions cmd/cli/kubectl-kyverno/data/crds/kyverno.io_clusterpolicies.yaml

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions cmd/cli/kubectl-kyverno/data/crds/kyverno.io_policies.yaml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions config/crds/kyverno/kyverno.io_cleanuppolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ spec:
- value
type: object
type: array
default:
description: |-
Default is an optional arbitrary JSON object that the context may take if the apiCall
returns error
x-kubernetes-preserve-unknown-fields: true
jmesPath:
description: |-
JMESPath is an optional JSON Match Expression that can be used to
Expand Down Expand Up @@ -1449,6 +1454,11 @@ spec:
- value
type: object
type: array
default:
description: |-
Default is an optional arbitrary JSON object that the context may take if the apiCall
returns error
x-kubernetes-preserve-unknown-fields: true
jmesPath:
description: |-
JMESPath is an optional JSON Match Expression that can be used to
Expand Down
10 changes: 10 additions & 0 deletions config/crds/kyverno/kyverno.io_clustercleanuppolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ spec:
- value
type: object
type: array
default:
description: |-
Default is an optional arbitrary JSON object that the context may take if the apiCall
returns error
x-kubernetes-preserve-unknown-fields: true
jmesPath:
description: |-
JMESPath is an optional JSON Match Expression that can be used to
Expand Down Expand Up @@ -1449,6 +1454,11 @@ spec:
- value
type: object
type: array
default:
description: |-
Default is an optional arbitrary JSON object that the context may take if the apiCall
returns error
x-kubernetes-preserve-unknown-fields: true
jmesPath:
description: |-
JMESPath is an optional JSON Match Expression that can be used to
Expand Down
Loading

0 comments on commit cc966bf

Please sign in to comment.