Skip to content

Commit

Permalink
add plaintext object overrider
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick <[email protected]>
  • Loading branch information
Patrick0308 committed Aug 8, 2024
1 parent f2633a4 commit b3e85ef
Show file tree
Hide file tree
Showing 7 changed files with 587 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,50 @@ spec:
- path
type: object
type: array
yamlOverrider:
description: YamlOverrider represents the rules dedicated
to handling yaml data overrides
items:
properties:
path:
description: Path indicates the path of target field
type: string
subOverrider:
description: SubOverriders represents override rules
defined with plaintext overriders.
items:
description: |-
PlaintextOverrider is a simple overrider that overrides target fields
according to path, operator and value.
properties:
operator:
description: |-
Operator indicates the operation on target field.
Available operators are: add, replace and remove.
enum:
- add
- remove
- replace
type: string
path:
description: Path indicates the path of target
field
type: string
value:
description: |-
Value to be applied to target field.
Must be empty when operator is Remove.
x-kubernetes-preserve-unknown-fields: true
required:
- operator
- path
type: object
type: array
required:
- path
- subOverrider
type: object
type: array
type: object
targetCluster:
description: |-
Expand Down Expand Up @@ -605,6 +649,49 @@ spec:
- path
type: object
type: array
yamlOverrider:
description: YamlOverrider represents the rules dedicated to handling
yaml data overrides
items:
properties:
path:
description: Path indicates the path of target field
type: string
subOverrider:
description: SubOverriders represents override rules defined
with plaintext overriders.
items:
description: |-
PlaintextOverrider is a simple overrider that overrides target fields
according to path, operator and value.
properties:
operator:
description: |-
Operator indicates the operation on target field.
Available operators are: add, replace and remove.
enum:
- add
- remove
- replace
type: string
path:
description: Path indicates the path of target field
type: string
value:
description: |-
Value to be applied to target field.
Must be empty when operator is Remove.
x-kubernetes-preserve-unknown-fields: true
required:
- operator
- path
type: object
type: array
required:
- path
- subOverrider
type: object
type: array
type: object
resourceSelectors:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,50 @@ spec:
- path
type: object
type: array
yamlOverrider:
description: YamlOverrider represents the rules dedicated
to handling yaml data overrides
items:
properties:
path:
description: Path indicates the path of target field
type: string
subOverrider:
description: SubOverriders represents override rules
defined with plaintext overriders.
items:
description: |-
PlaintextOverrider is a simple overrider that overrides target fields
according to path, operator and value.
properties:
operator:
description: |-
Operator indicates the operation on target field.
Available operators are: add, replace and remove.
enum:
- add
- remove
- replace
type: string
path:
description: Path indicates the path of target
field
type: string
value:
description: |-
Value to be applied to target field.
Must be empty when operator is Remove.
x-kubernetes-preserve-unknown-fields: true
required:
- operator
- path
type: object
type: array
required:
- path
- subOverrider
type: object
type: array
type: object
targetCluster:
description: |-
Expand Down Expand Up @@ -605,6 +649,49 @@ spec:
- path
type: object
type: array
yamlOverrider:
description: YamlOverrider represents the rules dedicated to handling
yaml data overrides
items:
properties:
path:
description: Path indicates the path of target field
type: string
subOverrider:
description: SubOverriders represents override rules defined
with plaintext overriders.
items:
description: |-
PlaintextOverrider is a simple overrider that overrides target fields
according to path, operator and value.
properties:
operator:
description: |-
Operator indicates the operation on target field.
Available operators are: add, replace and remove.
enum:
- add
- remove
- replace
type: string
path:
description: Path indicates the path of target field
type: string
value:
description: |-
Value to be applied to target field.
Must be empty when operator is Remove.
x-kubernetes-preserve-unknown-fields: true
required:
- operator
- path
type: object
type: array
required:
- path
- subOverrider
type: object
type: array
type: object
resourceSelectors:
description: |-
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/policy/v1alpha1/override_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type RuleWithCluster struct {
// - LabelsOverrider
// - AnnotationsOverrider
// - Plaintext
// - PlaintextObjectOverrider
type Overriders struct {
// Plaintext represents override rules defined with plaintext overriders.
// +optional
Expand All @@ -126,6 +127,17 @@ type Overriders struct {
// AnnotationsOverrider represents the rules dedicated to handling workload annotations
// +optional
AnnotationsOverrider []LabelAnnotationOverrider `json:"annotationsOverrider,omitempty"`

// PlaintextObjectOverrider represents the rules dedicated to handling yaml or json data overrides
// +optional
PlaintextObjectOverrider []PlaintextObjectOverrider `json:"plaintextObjectOverrider,omitempty"`
}

type PlaintextObjectOverrider struct {
// Path indicates the path of target field
Path string `json:"path"`
// Plaintext represents override rules defined with plaintext overriders.
Plaintext []PlaintextOverrider `json:"plaintext"`
}

// LabelAnnotationOverrider represents the rules dedicated to handling workload labels/annotations
Expand Down
30 changes: 30 additions & 0 deletions pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go

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

56 changes: 54 additions & 2 deletions pkg/generated/openapi/zz_generated.openapi.go

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

Loading

0 comments on commit b3e85ef

Please sign in to comment.