func Cr(name, namespace string, client runtimeClient.Client) (*v1alpha1.NifiCluster, error) {
	cr := &v1alpha1.NifiCluster{}
	err := client.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: namespace}, cr)
	if err != nil {
		return nil, errors.WrapIfWithDetails(err, "could not get cr from k8s", "crName", name, "namespace", namespace)
	}
	return cr, nil
}
Cr returns the given cr object
package k8sutil
import (
	"context"
	"emperror.dev/errors"
	"github.com/Orange-OpenSource/nifikop/api/v1alpha1"
	"k8s.io/apimachinery/pkg/types"
	runtimeClient "sigs.k8s.io/controller-runtime/pkg/client"
	"strconv"
)
func AddNewNodeToCr(node v1alpha1.Node, crName, namespace string, client runtimeClient.Client) error {
	cr, err := Cr(crName, namespace, client)
	if err != nil {
		return err
	}
	cr.Spec.Nodes = append(cr.Spec.Nodes, node)
	return updateCr(cr, client)
}
func RemoveNodeFromCr(nodeId, crName, namespace string, client runtimeClient.Client) error {
	cr, err := Cr(crName, namespace, client)
	if err != nil {
		return err
	}
	tmpNodes := cr.Spec.Nodes[:0]
	for _, node := range cr.Spec.Nodes {
		if strconv.Itoa(int(node.Id)) != nodeId {
			tmpNodes = append(tmpNodes, node)
		}
	}
	cr.Spec.Nodes = tmpNodes
	return updateCr(cr, client)
}
func AddPvToSpecificNode(nodeId, crName, namespace string, storageConfig *v1alpha1.StorageConfig, client runtimeClient.Client) error {
	cr, err := Cr(crName, namespace, client)
	if err != nil {
		return err
	}
	tempConfigs := cr.Spec.Nodes[:0]
	for _, node := range cr.Spec.Nodes {
		if strconv.Itoa(int(node.Id)) == nodeId {
			node.NodeConfig.StorageConfigs = append(node.NodeConfig.StorageConfigs, *storageConfig)
		}
		tempConfigs = append(tempConfigs, node)
	}
	cr.Spec.Nodes = tempConfigs
	return updateCr(cr, client)
}