// GetSelectedCluster get selected cluster from PlacementDecision
GetSelectedCluster get selected cluster from PlacementDecision
// GetSelectedCluster get selected cluster from PlacementDecision
func (o *OCMEngine) GetSelectedCluster(ctx context.Context, name, namespace string) (string, error) {
	var clusterName string
	listOpts := []client.ListOption{
		client.MatchingLabels{
			"cluster.open-cluster-management.io/placement": name,
		},
		client.InNamespace(namespace),
	}
	pdList := new(ocmclusterv1alpha1.PlacementDecisionList)
	err := o.cli.List(ctx, pdList, listOpts...)
	if err != nil {
		return clusterName, err
	}
	if len(pdList.Items) < 1 {
		return clusterName, errors.New("fail to get PlacementDecision")
	}
	if len(pdList.Items[0].Status.Decisions) < 1 {
		return clusterName, errors.New("no matched cluster")
	}
	clusterName = pdList.Items[0].Status.Decisions[0].ClusterName
	return clusterName, nil
}
func ( o * OCMEngine ) GetSelectedCluster ( ctx context . Context , name , namespace string ) ( string , error ) { var clusterName string listOpts := [ ] client . ListOption { client . MatchingLabels { " " : name , } , client . InNamespace ( namespace ) , } pdList := new ( ocmclusterv1alpha1 . PlacementDecisionList ) err := o . cli . List ( ctx , pdList , listOpts ... ) if err != nil { return clusterName , err } if len ( pdList . Items ) < 1 { return clusterName , errors . New ( " " ) } if len ( pdList . Items [ 0 ] . Status . Decisions ) < 1 { return clusterName , errors . New ( " " ) } clusterName = pdList . Items [ 0 ] . Status . Decisions [ 0 ] . ClusterName return clusterName , nil }
GetSelectedCluster get selected cluster from PlacementDecision
GetSelectedCluster get selected cluster from PlacementDecision