// DispatchPlacement dispatch Placement Object of OCM for cluster selected
DispatchPlacement dispatch Placement Object of OCM for cluster selected
// DispatchPlacement dispatch Placement Object of OCM for cluster selected
func (o *OCMEngine) DispatchPlacement(ctx context.Context, config v1alpha1.EnvConfig) error {
	placement := new(ocmclusterv1alpha1.Placement)
	placementName := generatePlacementName(o.appName, config.Name)
	placement.SetName(placementName)
	placement.SetNamespace(o.appNs)
	clusterNum := int32(1)
	placement.Spec.NumberOfClusters = &clusterNum
	placement.Spec.Predicates = []ocmclusterv1alpha1.ClusterPredicate{{
		RequiredClusterSelector: ocmclusterv1alpha1.ClusterSelector{
			LabelSelector: metav1.LabelSelector{
				MatchLabels: config.Placement.ClusterSelector.Labels,
			},
		},
	}}
	oldPd := new(ocmclusterv1alpha1.Placement)
	if err := o.cli.Get(ctx, client.ObjectKey{Namespace: placement.Namespace, Name: placement.Name}, oldPd); err != nil {
		if kerrors.IsNotFound(err) {
			return o.cli.Create(ctx, placement)
		}
		return err
	}
	return o.cli.Patch(ctx, placement, client.Merge)
}
func ( o * OCMEngine ) DispatchPlacement ( ctx context . Context , config v1alpha1 . EnvConfig ) error { placement := new ( ocmclusterv1alpha1 . Placement ) placementName := generatePlacementName ( o . appName , config . Name ) placement . SetName ( placementName ) placement . SetNamespace ( o . appNs ) clusterNum := int32 ( 1 ) placement . Spec . NumberOfClusters = & clusterNum placement . Spec . Predicates = [ ] ocmclusterv1alpha1 . ClusterPredicate { { RequiredClusterSelector : ocmclusterv1alpha1 . ClusterSelector { LabelSelector : metav1 . LabelSelector { MatchLabels : config . Placement . ClusterSelector . Labels , } , } , } } oldPd := new ( ocmclusterv1alpha1 . Placement ) if err := o . cli . Get ( ctx , client . ObjectKey { Namespace : placement . Namespace , Name : placement . Name } , oldPd ) ; err != nil { if kerrors . IsNotFound ( err ) { return o . cli . Create ( ctx , placement ) } return err } return o . cli . Patch ( ctx , placement , client . Merge ) }
DispatchPlacement dispatch Placement Object of OCM for cluster selected
DispatchPlacement dispatch Placement Object of OCM for cluster selected