Skip to content

Commit

Permalink
Update description and add objectHash annotation
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Qiu <[email protected]>
  • Loading branch information
qiujian16 committed Nov 26, 2024
1 parent f777e4a commit 1d0a8b8
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,32 @@ spec:
paths in the resource that will not be updated
on the spoke.
items:
type: string
properties:
condition:
default: OnSpokePresent
description: |-
Condition defines the condition that the fields should be ignored when apply the resource.
Fields in JSONPaths are all ignored when condition is met, otherwise no fields is ignored
in the apply operation.
enum:
- OnSpokePresent
- OnSpokeChange
type: string
jsonPaths:
description: JSONPaths defines the list of
json path in the resource to be ignored
items:
type: string
minItems: 1
type: array
required:
- condition
- jsonPaths
type: object
type: array
onSpokeChange:
default: Override
description: |-
OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
on the spoke by another actor.
enum:
- Override
- NoOverride
type: string
required:
- onSpokeChange
x-kubernetes-list-map-keys:
- condition
x-kubernetes-list-type: map
type: object
type:
default: Update
Expand All @@ -302,17 +315,6 @@ 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 @@ -253,19 +253,32 @@ spec:
description: IgnoreFields defines a list of json paths
in the resource that will not be updated on the spoke.
items:
type: string
properties:
condition:
default: OnSpokePresent
description: |-
Condition defines the condition that the fields should be ignored when apply the resource.
Fields in JSONPaths are all ignored when condition is met, otherwise no fields is ignored
in the apply operation.
enum:
- OnSpokePresent
- OnSpokeChange
type: string
jsonPaths:
description: JSONPaths defines the list of json
path in the resource to be ignored
items:
type: string
minItems: 1
type: array
required:
- condition
- jsonPaths
type: object
type: array
onSpokeChange:
default: Override
description: |-
OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
on the spoke by another actor.
enum:
- Override
- NoOverride
type: string
required:
- onSpokeChange
x-kubernetes-list-map-keys:
- condition
x-kubernetes-list-type: map
type: object
type:
default: Update
Expand All @@ -284,17 +297,6 @@ 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
44 changes: 29 additions & 15 deletions work/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,10 @@ type UpdateStrategy struct {
// 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
type IgnoreFieldsCondition string

const (
// UpdateStrategyTypeUpdate means to update resource by an update call.
Expand All @@ -200,6 +197,13 @@ const (
// 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"

// IgnoreFieldsConditionOnSpokeChange is the condition when resource fields is updated by another actor
// on the spoke cluster.
IgnoreFieldsConditionOnSpokeChange IgnoreFieldsCondition = "OnSpokeChange"

// IgnoreFieldsConditionOnSpokePresent is the condition when the resource exist on the spoke cluster.
IgnoreFieldsConditionOnSpokePresent IgnoreFieldsCondition = "OnSpokePresent"
)

type ServerSideApplyConfig struct {
Expand All @@ -215,21 +219,27 @@ type ServerSideApplyConfig struct {
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"`
// +listType:=map
// +listMapKey:=condition
// +optional
IgnoreFields []IgnoreField `json:"ignoreFields,omitempty"`
}

// OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
// on the spoke by another actor.
// +kubebuilder:default=Override
// +kubebuilder:validation:Enum=Override;NoOverride
type IgnoreField struct {
// Condition defines the condition that the fields should be ignored when apply the resource.
// Fields in JSONPaths are all ignored when condition is met, otherwise no fields is ignored
// in the apply operation.
// +kubebuilder:default=OnSpokePresent
// +kubebuilder:validation:Enum=OnSpokePresent;OnSpokeChange
// +kubebuilder:validation:Required
// +required
OnSpokeChange string `json:"onSpokeChange,omitempty"`
}
Condition IgnoreFieldsCondition `json:"condition"`

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"`
// JSONPaths defines the list of json path in the resource to be ignored
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
// +required
JSONPaths []string `json:"jsonPaths"`
}

// DefaultFieldManager is the default field manager of the manifestwork when the field manager is not set.
Expand Down Expand Up @@ -525,6 +535,10 @@ const (
// ensure all resource relates to appliedmanifestwork is deleted before appliedmanifestwork itself
// is deleted.
AppliedManifestWorkFinalizer = "cluster.open-cluster-management.io/applied-manifest-work-cleanup"

// ObjectSpecHash is the key of the annotation on the applied resources. The value is the computed hash
// from the resource manifests in the manifestwork.
ObjectSpecHash = "open-cluster-management.io/object-hash"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
48 changes: 25 additions & 23 deletions work/v1/zz_generated.deepcopy.go

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

25 changes: 12 additions & 13 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 @@ -278,19 +278,32 @@ spec:
paths in the resource that will not be updated
on the spoke.
items:
type: string
properties:
condition:
default: OnSpokePresent
description: |-
Condition defines the condition that the fields should be ignored when apply the resource.
Fields in JSONPaths are all ignored when condition is met, otherwise no fields is ignored
in the apply operation.
enum:
- OnSpokePresent
- OnSpokeChange
type: string
jsonPaths:
description: JSONPaths defines the list of
json path in the resource to be ignored
items:
type: string
minItems: 1
type: array
required:
- condition
- jsonPaths
type: object
type: array
onSpokeChange:
default: Override
description: |-
OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed
on the spoke by another actor.
enum:
- Override
- NoOverride
type: string
required:
- onSpokeChange
x-kubernetes-list-map-keys:
- condition
x-kubernetes-list-type: map
type: object
type:
default: Update
Expand All @@ -309,17 +322,6 @@ 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 1d0a8b8

Please sign in to comment.