Skip to content

Commit

Permalink
Add an option to select override resource by mw
Browse files Browse the repository at this point in the history
The option is to disable overrid resource on the spoke by manifestwork
when the resource is changed by another actor on the spoke

Signed-off-by: Jian Qiu <[email protected]>
  • Loading branch information
qiujian16 committed Nov 12, 2024
1 parent db876bf commit 26ec0c7
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ spec:
properties:
serverSideApply:
description: |-
serverSideApply defines the configuration for server side apply. It is honored only when
type of updateStrategy is ServerSideApply
serverSideApply defines the configuration for server side apply. It is honored only when the
type of the updateStrategy is ServerSideApply
properties:
fieldManager:
default: work-agent
Expand All @@ -266,6 +266,18 @@ spec:
description: Force represents to force apply the
manifest.
type: boolean
ignoreFields:
description: IgnoreFields defines a list of json
paths in the resource that will not be updated
on the spoke.
items:
type: string
type: array
onSpokeChange:
description: |-
OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
on the spoke by another actor.
type: string
type: object
type:
default: Update
Expand All @@ -284,6 +296,17 @@ spec:
- ServerSideApply
- ReadOnly
type: string
update:
description: |-
update defines the configuration for update. It is honored only when the type of the updateStrategy
is Update
properties:
onSpokeChange:
description: |-
OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
on the spoke by another actor.
type: string
type: object
required:
- type
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ spec:
properties:
serverSideApply:
description: |-
serverSideApply defines the configuration for server side apply. It is honored only when
type of updateStrategy is ServerSideApply
serverSideApply defines the configuration for server side apply. It is honored only when the
type of the updateStrategy is ServerSideApply
properties:
fieldManager:
default: work-agent
Expand All @@ -249,6 +249,17 @@ spec:
force:
description: Force represents to force apply the manifest.
type: boolean
ignoreFields:
description: IgnoreFields defines a list of json paths
in the resource that will not be updated on the spoke.
items:
type: string
type: array
onSpokeChange:
description: |-
OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
on the spoke by another actor.
type: string
type: object
type:
default: Update
Expand All @@ -267,6 +278,17 @@ spec:
- ServerSideApply
- ReadOnly
type: string
update:
description: |-
update defines the configuration for update. It is honored only when the type of the updateStrategy
is Update
properties:
onSpokeChange:
description: |-
OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
on the spoke by another actor.
type: string
type: object
required:
- type
type: object
Expand Down
21 changes: 19 additions & 2 deletions work/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,14 @@ type UpdateStrategy struct {
// +required
Type UpdateStrategyType `json:"type,omitempty"`

// serverSideApply defines the configuration for server side apply. It is honored only when
// type of updateStrategy is ServerSideApply
// serverSideApply defines the configuration for server side apply. It is honored only when the
// type of the updateStrategy is ServerSideApply
// +optional
ServerSideApply *ServerSideApplyConfig `json:"serverSideApply,omitempty"`

// update defines the configuration for update. It is honored only when the type of the updateStrategy
// is Update
Update *UpdateConfig `json:"update,omitempty"`
}

type UpdateStrategyType string
Expand Down Expand Up @@ -209,6 +213,19 @@ type ServerSideApplyConfig struct {
// +kubebuilder:validation:Pattern=`^work-agent`
// +optional
FieldManager string `json:"fieldManager,omitempty"`

// IgnoreFields defines a list of json paths in the resource that will not be updated on the spoke.
IgnoreFields []string `json:"ignoreFields,omitempty"`

// OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
// on the spoke by another actor.
OnSpokeChange string `json:"onSpokeChange,omitempty"`
}

type UpdateConfig struct {
// OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
// on the spoke by another actor.
OnSpokeChange string `json:"onSpokeChange,omitempty"`
}

// DefaultFieldManager is the default field manager of the manifestwork when the field manager is not set.
Expand Down
26 changes: 26 additions & 0 deletions work/v1/zz_generated.deepcopy.go

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

17 changes: 14 additions & 3 deletions work/v1/zz_generated.swagger_doc_generated.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 @@ -259,8 +259,8 @@ spec:
properties:
serverSideApply:
description: |-
serverSideApply defines the configuration for server side apply. It is honored only when
type of updateStrategy is ServerSideApply
serverSideApply defines the configuration for server side apply. It is honored only when the
type of the updateStrategy is ServerSideApply
properties:
fieldManager:
default: work-agent
Expand All @@ -273,6 +273,18 @@ spec:
description: Force represents to force apply the
manifest.
type: boolean
ignoreFields:
description: IgnoreFields defines a list of json
paths in the resource that will not be updated
on the spoke.
items:
type: string
type: array
onSpokeChange:
description: |-
OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
on the spoke by another actor.
type: string
type: object
type:
default: Update
Expand All @@ -291,6 +303,17 @@ spec:
- ServerSideApply
- ReadOnly
type: string
update:
description: |-
update defines the configuration for update. It is honored only when the type of the updateStrategy
is Update
properties:
onSpokeChange:
description: |-
OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
on the spoke by another actor.
type: string
type: object
required:
- type
type: object
Expand Down

0 comments on commit 26ec0c7

Please sign in to comment.