package util import ( "context" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" ) const ( // NamespaceClusterLease is the namespace which cluster lease are stored. NamespaceClusterLease = "karmada-cluster" ) // IsClusterReady tells whether the cluster status in 'Ready' condition. func IsClusterReady(clusterStatus *v1alpha1.ClusterStatus) bool { return meta.IsStatusConditionTrue(clusterStatus.Conditions, v1alpha1.ClusterConditionReady) } // GetCluster returns the given Cluster resource func GetCluster(hostClient client.Client, clusterName string) (*v1alpha1.Cluster, error) { cluster := &v1alpha1.Cluster{} if err := hostClient.Get(context.TODO(), types.NamespacedName{Name: clusterName}, cluster); err != nil { return nil, err } return cluster, nil }