func HomeDir() string {
	if h := os.Getenv("HOME"); h != "" {
		return h
	}
	return os.Getenv("USERPROFILE")
}
HomeDir returns home dir
package k8s
import (
	"context"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/apimachinery/pkg/watch"
	"k8s.io/client-go/dynamic"
	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/clientcmd"
	"os"
	"path/filepath"
)
func WrapDClient(client dynamic.Interface) DClient {
	return &ClusterDynamicClient{
		dClient: client,
	}
}
type DClient interface {
	WithResource(resource schema.GroupVersionResource) DClient
	WithNamespace(namespace string) DClient
	WithContext(ctx context.Context) DClient
	Create(obj *unstructured.Unstructured, options metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error)
	Update(obj *unstructured.Unstructured, options metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error)
	Delete(name string, options metav1.DeleteOptions, subresources ...string) error
	Get(name string, options metav1.GetOptions, subresources ...string) (*unstructured.Unstructured, error)
	List(opts metav1.ListOptions) (*unstructured.UnstructuredList, error)
}
type ClusterDynamicClient struct {
	dClient   dynamic.Interface
	namespace string
	resource  schema.GroupVersionResource
	ctx       context.Context
}
func (w *ClusterDynamicClient) WithResource(resource schema.GroupVersionResource) DClient {
	w.resource = resource
	return w
}
func (w *ClusterDynamicClient) WithNamespace(namespace string) DClient {
	w.namespace = namespace
	return w
}
func (w *ClusterDynamicClient) WithContext(ctx context.Context) DClient {
	w.ctx = ctx
	return w
}
func (w *ClusterDynamicClient) Create(obj *unstructured.Unstructured, options metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error) {
	return w.dClient.Resource(w.resource).Namespace(w.namespace).Create(w.ctx, obj, options, subresources...)
}
func (w *ClusterDynamicClient) Update(obj *unstructured.Unstructured, options metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) {
	return w.dClient.Resource(w.resource).Namespace(w.namespace).Update(w.ctx, obj, options, subresources...)
}
func (w *ClusterDynamicClient) UpdateStatus(obj *unstructured.Unstructured, options metav1.UpdateOptions) (*unstructured.Unstructured, error) {
	return w.dClient.Resource(w.resource).Namespace(w.namespace).UpdateStatus(w.ctx, obj, options)
}
func (w *ClusterDynamicClient) Delete(name string, options metav1.DeleteOptions, subresources ...string) error {
	return w.dClient.Resource(w.resource).Namespace(w.namespace).Delete(w.ctx, name, options, subresources...)
}
func (w *ClusterDynamicClient) DeleteCollection(options metav1.DeleteOptions, listOptions metav1.ListOptions) error {
	return w.dClient.Resource(w.resource).Namespace(w.namespace).DeleteCollection(w.ctx, options, listOptions)
}
func (w *ClusterDynamicClient) Get(name string, options metav1.GetOptions, subresources ...string) (*unstructured.Unstructured, error) {
	return w.dClient.Resource(w.resource).Namespace(w.namespace).Get(w.ctx, name, options, subresources...)
}
func (w *ClusterDynamicClient) List(opts metav1.ListOptions) (*unstructured.UnstructuredList, error) {
	return w.dClient.Resource(w.resource).Namespace(w.namespace).List(w.ctx, opts)
}
func (w *ClusterDynamicClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
	return w.dClient.Resource(w.resource).Namespace(w.namespace).Watch(w.ctx, opts)
}
func (w *ClusterDynamicClient) Patch(name string, pt types.PatchType, data []byte, options metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error) {
	return w.dClient.Resource(w.resource).Namespace(w.namespace).Patch(w.ctx, name, pt, data, options, subresources...)
}
func NewDynamicClient() (dynamic.Interface, error) {
	var config *rest.Config
	var err error
	config, err = rest.InClusterConfig()
	if err != nil {
		config, err = ExternalConfig()
		if err != nil {
			return nil, err
		}
	}
	dynamicClient, err := dynamic.NewForConfig(config)
	if err != nil {
		return nil, err
	}
	return dynamicClient, nil
}