func (k *Kubeclient) Delete(name string, options *metav1.DeleteOptions) error {
	cli, err := k.getClientOrCached()
	if err != nil {
		return err
	}
	return k.del(cli, name, k.namespace, options)
}
Delete returns service object for given name
package service
import (
	"context"
	"encoding/json"
	"github.com/openebs/dynamic-nfs-provisioner/pkg/kubernetes/client"
	"github.com/pkg/errors"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	types "k8s.io/apimachinery/pkg/types"
	"k8s.io/client-go/kubernetes"
)
type getClientsetFn func() (clientset *kubernetes.Clientset, err error)
type getClientsetForPathFn func(
	kubeConfigPath string,
) (*kubernetes.Clientset, error)
type getFn func(
	cli *kubernetes.Clientset,
	name, namespace string,
	opts metav1.GetOptions,
) (*corev1.Service, error)
type listFn func(
	cli *kubernetes.Clientset,
	namespace string,
	opts metav1.ListOptions,
) (*corev1.ServiceList, error)
type delFn func(
	cli *kubernetes.Clientset,
	name, namespace string,
	opts *metav1.DeleteOptions,
) error
type createFn func(
	cli *kubernetes.Clientset,
	service *corev1.Service,
	namespace string,
	opts metav1.CreateOptions,
) (*corev1.Service, error)
type updateFn func(
	cli *kubernetes.Clientset,
	service *corev1.Service,
	namespace string,
	opts metav1.UpdateOptions,
) (*corev1.Service, error)
type patchFn func(
	cli *kubernetes.Clientset,
	name, namespace string,
	pt types.PatchType,
	data []byte,
	opts metav1.PatchOptions,
	subresources ...string,
) (*corev1.Service, error)
type Kubeclient struct {
	clientset *kubernetes.Clientset
	namespace string
	kubeConfigPath string
	getClientset        getClientsetFn
	getClientsetForPath getClientsetForPathFn
	list                listFn
	get                 getFn
	del                 delFn
	create              createFn
	patch               patchFn
	update              updateFn
}
type KubeclientBuildOption func(*Kubeclient)
func defaultGetClientset() (clients *kubernetes.Clientset, err error) {
	config, err := client.New().Config()
	if err != nil {
		return nil, err
	}
	return kubernetes.NewForConfig(config)
}
func defaultGetClientsetForPath(
	kubeConfigPath string,
) (clients *kubernetes.Clientset, err error) {
	return client.New(client.WithKubeConfigPath(kubeConfigPath)).
		Clientset()
}
func defaultGet(
	cli *kubernetes.Clientset,
	name, namespace string,
	opts metav1.GetOptions,
) (r *corev1.Service, err error) {
	r, err = cli.CoreV1().
		Services(namespace).
		Get(context.TODO(), name, opts)
	return
}
func defaultList(
	cli *kubernetes.Clientset,
	namespace string,
	opts metav1.ListOptions,
) (rl *corev1.ServiceList, err error) {
	rl, err = cli.CoreV1().
		Services(namespace).
		List(context.TODO(), opts)
	return
}
func defaultDel(
	cli *kubernetes.Clientset,
	name, namespace string,
	opts *metav1.DeleteOptions,
) (err error) {
	deletePropagation := metav1.DeletePropagationForeground
	opts.PropagationPolicy = &deletePropagation
	err = cli.CoreV1().
		Services(namespace).
		Delete(context.TODO(), name, *opts)
	return
}
func defaultCreate(
	cli *kubernetes.Clientset,
	service *corev1.Service,
	namespace string,
	opts metav1.CreateOptions,
) (*corev1.Service, error) {
	return cli.CoreV1().
		Services(namespace).
		Create(context.TODO(), service, opts)
}
func defaultUpdate(
	cli *kubernetes.Clientset,
	service *corev1.Service,
	namespace string,
	opts metav1.UpdateOptions,
) (*corev1.Service, error) {
	return cli.CoreV1().
		Services(namespace).
		Update(context.TODO(), service, opts)
}
func defaultPatch(
	cli *kubernetes.Clientset,
	name, namespace string,
	pt types.PatchType,
	data []byte,
	opts metav1.PatchOptions,
	subresources ...string,
) (*corev1.Service, error) {
	return cli.CoreV1().
		Services(namespace).
		Patch(context.TODO(), name, pt, data, opts, subresources...)
}
func (k *Kubeclient) withDefaults() {
	if k.getClientset == nil {
		k.getClientset = defaultGetClientset
	}
	if k.getClientsetForPath == nil {
		k.getClientsetForPath = defaultGetClientsetForPath
	}
	if k.get == nil {
		k.get = defaultGet
	}
	if k.list == nil {
		k.list = defaultList
	}
	if k.del == nil {
		k.del = defaultDel
	}
	if k.create == nil {
		k.create = defaultCreate
	}
	if k.patch == nil {
		k.patch = defaultPatch
	}
	if k.update == nil {
		k.update = defaultUpdate
	}
}
func WithClientset(c *kubernetes.Clientset) KubeclientBuildOption {
	return func(k *Kubeclient) {
		k.clientset = c
	}
}
func WithNamespace(namespace string) KubeclientBuildOption {
	return func(k *Kubeclient) {
		k.namespace = namespace
	}
}
func (k *Kubeclient) WithNamespace(namespace string) *Kubeclient {
	k.namespace = namespace
	return k
}
func WithKubeConfigPath(path string) KubeclientBuildOption {
	return func(k *Kubeclient) {
		k.kubeConfigPath = path
	}
}
func NewKubeClient(opts ...KubeclientBuildOption) *Kubeclient {
	k := &Kubeclient{}
	for _, o := range opts {
		o(k)
	}
	k.withDefaults()
	return k
}
func (k *Kubeclient) getClientsetForPathOrDirect() (
	*kubernetes.Clientset, error) {
	if k.kubeConfigPath != "" {
		return k.getClientsetForPath(k.kubeConfigPath)
	}
	return k.getClientset()
}
func (k *Kubeclient) getClientOrCached() (*kubernetes.Clientset, error) {
	if k.clientset != nil {
		return k.clientset, nil
	}
	cs, err := k.getClientsetForPathOrDirect()
	if err != nil {
		return nil, errors.Wrapf(err, "failed to get clientset")
	}
	k.clientset = cs
	return k.clientset, nil
}
func (k *Kubeclient) Get(name string, opts metav1.GetOptions) (
	*corev1.Service, error) {
	cli, err := k.getClientOrCached()
	if err != nil {
		return nil, err
	}
	return k.get(cli, name, k.namespace, opts)
}
func (k *Kubeclient) GetRaw(name string, opts metav1.GetOptions) (
	[]byte, error) {
	svc, err := k.Get(name, opts)
	if err != nil {
		return nil, err
	}
	return json.Marshal(svc)
}
func (k *Kubeclient) List(opts metav1.ListOptions) (
	*corev1.ServiceList, error) {
	cli, err := k.getClientOrCached()
	if err != nil {
		return nil, err
	}
	return k.list(cli, k.namespace, opts)
}
func (k *Kubeclient) ListRaw(opts metav1.ListOptions) ([]byte, error) {
	svcList, err := k.List(opts)
	if err != nil {
		return nil, err
	}
	return json.Marshal(svcList)
}