feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
committed by
GitHub
parent
b5015ec7b9
commit
447a51f08b
46
pkg/controller/cluster/predicate/predicate.go
Normal file
46
pkg/controller/cluster/predicate/predicate.go
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package predicate
|
||||
|
||||
import (
|
||||
clusterv1alpha1 "kubesphere.io/api/cluster/v1alpha1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/event"
|
||||
"sigs.k8s.io/controller-runtime/pkg/predicate"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/controller/cluster/utils"
|
||||
)
|
||||
|
||||
type ClusterStatusChangedPredicate struct {
|
||||
predicate.Funcs
|
||||
}
|
||||
|
||||
func (ClusterStatusChangedPredicate) Update(e event.UpdateEvent) bool {
|
||||
oldCluster, ok := e.ObjectOld.(*clusterv1alpha1.Cluster)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
newCluster := e.ObjectNew.(*clusterv1alpha1.Cluster)
|
||||
// cluster is ready
|
||||
if !utils.IsClusterReady(oldCluster) && utils.IsClusterReady(newCluster) {
|
||||
return true
|
||||
}
|
||||
if !utils.IsClusterSchedulable(oldCluster) && utils.IsClusterSchedulable(newCluster) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (ClusterStatusChangedPredicate) Create(_ event.CreateEvent) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ClusterStatusChangedPredicate) Delete(_ event.DeleteEvent) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ClusterStatusChangedPredicate) Generic(_ event.GenericEvent) bool {
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user