Skip to content

Commit

Permalink
ReadOnly type in work (#332)
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Qiu <[email protected]>
  • Loading branch information
qiujian16 authored May 31, 2024
1 parent cf2d921 commit bda2bdc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,14 @@ spec:
server side apply with work-controller as the field
manager. If there is conflict, the related Applied
condition of manifest will be in the status of False
with the reason of ApplyConflict.
with the reason of ApplyConflict. ReadOnly type means
the agent will only check the existence of the resource
based on its metadata.
enum:
- Update
- CreateOnly
- ServerSideApply
- ReadOnly
type: string
required:
- type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,14 @@ spec:
means to update resource using server side apply with
work-controller as the field manager. If there is conflict,
the related Applied condition of manifest will be in the
status of False with the reason of ApplyConflict.
status of False with the reason of ApplyConflict. ReadOnly
type means the agent will only check the existence of
the resource based on its metadata.
enum:
- Update
- CreateOnly
- ServerSideApply
- ReadOnly
type: string
required:
- type
Expand Down
14 changes: 10 additions & 4 deletions work/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ type UpdateStrategy struct {
// ServerSideApply type means to update resource using server side apply with work-controller as the field manager.
// If there is conflict, the related Applied condition of manifest will be in the status of False with the
// reason of ApplyConflict.
// ReadOnly type means the agent will only check the existence of the resource based on its metadata.
// +kubebuilder:default=Update
// +kubebuilder:validation:Enum=Update;CreateOnly;ServerSideApply
// +kubebuilder:validation:Enum=Update;CreateOnly;ServerSideApply;ReadOnly
// +kubebuilder:validation:Required
// +required
Type UpdateStrategyType `json:"type,omitempty"`
Expand All @@ -177,18 +178,23 @@ type UpdateStrategy struct {
type UpdateStrategyType string

const (
// Update type means to update resource by an update call.
// UpdateStrategyTypeUpdate means to update resource by an update call.
UpdateStrategyTypeUpdate UpdateStrategyType = "Update"

// CreateOnly type means do not update resource based on current manifest. This should be used only when
// UpdateStrategyTypeCreateOnly means do not update resource based on current manifest. This should be used only when
// ServerSideApply type is not support on the spoke, and the user on hub would like some other controller
// on the spoke to own the control of the resource.
UpdateStrategyTypeCreateOnly UpdateStrategyType = "CreateOnly"

// ServerSideApply type means to update resource using server side apply with work-controller as the field manager.
// UpdateStrategyTypeServerSideApply means to update resource using server side apply with work-controller as the field manager.
// If there is conflict, the related Applied condition of manifest will be in the status of False with the
// reason of ApplyConflict. This type allows another controller on the spoke to control certain field of the resource.
UpdateStrategyTypeServerSideApply UpdateStrategyType = "ServerSideApply"

// UpdateStrategyTypeReadOnly type means only check the existence of the resource based on the resource's metadata.
// If the statusFeedBackRules are set, the feedbackResult will also be returned.
// The resource will not be removed when the type is ReadOnly, and only resource metadata is required.
UpdateStrategyTypeReadOnly UpdateStrategyType = "ReadOnly"
)

type ServerSideApplyConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion 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 @@ -284,11 +284,14 @@ spec:
server side apply with work-controller as the field
manager. If there is conflict, the related Applied
condition of manifest will be in the status of False
with the reason of ApplyConflict.
with the reason of ApplyConflict. ReadOnly type means
the agent will only check the existence of the resource
based on its metadata.
enum:
- Update
- CreateOnly
- ServerSideApply
- ReadOnly
type: string
required:
- type
Expand Down

0 comments on commit bda2bdc

Please sign in to comment.