Skip to content

Commit

Permalink
feat: support excluded sync resources
Browse files Browse the repository at this point in the history
Signed-off-by: KubeKyrie <shaolong.qin@daocloud.io>
  • Loading branch information
KubeKyrie committed Dec 28, 2023
1 parent 810c6c4 commit 313a7a4
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ spec:
syncResources:
items:
properties:
excludedResource:
items:
type: string
type: array
group:
type: string
resources:
Expand Down
4 changes: 4 additions & 0 deletions kustomize/crds/cluster.clusterpedia.io_pediaclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ spec:
syncResources:
items:
properties:
excludedResource:
items:
type: string
type: array
group:
type: string
resources:
Expand Down
14 changes: 14 additions & 0 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.

4 changes: 4 additions & 0 deletions pkg/synchromanager/clustersynchro/resource_negotiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ func (negotiator *ResourceNegotiator) NegotiateSyncResources(syncResources []clu
var groupResourceStatus = NewGroupResourceStatus()
var storageResourceSyncConfigs = make(map[schema.GroupVersionResource]syncConfig)
for _, groupResources := range syncResources {
excludedResourcesSet := sets.New(groupResources.ExcludedResource...)
for _, resource := range groupResources.Resources {
if excludedResourcesSet.Has(resource) {
continue
}
syncGR := schema.GroupResource{Group: groupResources.Group, Resource: resource}
apiResource, supportedVersions := negotiator.dynamicDiscovery.GetAPIResourceAndVersions(syncGR)
if apiResource == nil || len(supportedVersions) == 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ type ClusterGroupResources struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
Resources []string `json:"resources"`

// +optional
ExcludedResource []string `json:"excludedResource"`
}

type ClusterStatus struct {
Expand Down

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

0 comments on commit 313a7a4

Please sign in to comment.