restrict override operation (#123)
Signed-off-by: RainbowMango <renhongcai@huawei.com>
This commit is contained in:
parent
2e9f245304
commit
1ee618a051
|
@ -50,7 +50,11 @@ spec:
|
||||||
properties:
|
properties:
|
||||||
operator:
|
operator:
|
||||||
description: 'Operator indicates the operation on target
|
description: 'Operator indicates the operation on target
|
||||||
field. Available operators are: Add, Update and Remove.'
|
field. Available operators are: add, update and remove.'
|
||||||
|
enum:
|
||||||
|
- add
|
||||||
|
- remove
|
||||||
|
- replace
|
||||||
type: string
|
type: string
|
||||||
path:
|
path:
|
||||||
description: Path indicates the path of target field
|
description: Path indicates the path of target field
|
||||||
|
|
|
@ -8,7 +8,7 @@ spec:
|
||||||
resourceSelectors:
|
resourceSelectors:
|
||||||
- apiVersion: apps/v1
|
- apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
name: # user can either select resource by name or by labelselector
|
name: nginx # user can either select resource by name or by labelselector
|
||||||
labelSelector:
|
labelSelector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
image: nginx
|
image: nginx
|
||||||
|
@ -24,11 +24,11 @@ spec:
|
||||||
overriders:
|
overriders:
|
||||||
plaintext:
|
plaintext:
|
||||||
- path: "/spec/template/spec/containers/0/image"
|
- path: "/spec/template/spec/containers/0/image"
|
||||||
operator: Replace
|
operator: replace
|
||||||
value: "dc-1.registry.io/nginx:1.17.0-alpine"
|
value: "dc-1.registry.io/nginx:1.17.0-alpine"
|
||||||
- path: "/metadata/annotations"
|
- path: "/metadata/annotations"
|
||||||
operator: Add
|
operator: add
|
||||||
value:
|
value:
|
||||||
foo: bar
|
foo: bar
|
||||||
- path: "/metadata/annotations/foo"
|
- path: "/metadata/annotations/foo"
|
||||||
operator: Remove
|
operator: remove
|
||||||
|
|
|
@ -42,7 +42,8 @@ type PlaintextOverrider struct {
|
||||||
// Path indicates the path of target field
|
// Path indicates the path of target field
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
// Operator indicates the operation on target field.
|
// Operator indicates the operation on target field.
|
||||||
// Available operators are: Add, Update and Remove.
|
// Available operators are: add, update and remove.
|
||||||
|
// +kubebuilder:validation:Enum=add;remove;replace
|
||||||
Operator OverriderOperator `json:"operator"`
|
Operator OverriderOperator `json:"operator"`
|
||||||
// Value to be applied to target field.
|
// Value to be applied to target field.
|
||||||
// Must be empty when operator is Remove.
|
// Must be empty when operator is Remove.
|
||||||
|
@ -55,9 +56,9 @@ type OverriderOperator string
|
||||||
|
|
||||||
// These are valid overrider operators.
|
// These are valid overrider operators.
|
||||||
const (
|
const (
|
||||||
OverriderOpAdd OverriderOperator = "Add"
|
OverriderOpAdd OverriderOperator = "add"
|
||||||
OverriderOpRemove OverriderOperator = "Remove"
|
OverriderOpRemove OverriderOperator = "remove"
|
||||||
OverriderOpReplace OverriderOperator = "Replace"
|
OverriderOpReplace OverriderOperator = "replace"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
Loading…
Reference in New Issue