func (k *KConf) hasUser(user *clientcmdapi.AuthInfo) bool {
	var foundUser bool
	for _, u := range k.AuthInfos {
		if reflect.DeepEqual(u, user) == true {
			foundUser = true
			break
		}
	}
	return foundUser
}
hasUser checks whether the KConf already contains the given AuthInfo
package kubeconfig
import (
	"fmt"
	"os"
	"path"
	"reflect"
	clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)
type Configurable interface {
	AddContext() bool
	AddCluster() bool
	AddUser() bool
	hasContext() bool
	hasCluster() bool
	hasUser() bool
	rename() string
}
type KConf struct {
	clientcmdapi.Config
}
var MainConfigPath string
func init() {
	MainConfigPath = path.Join(os.Getenv("HOME"), ".kube", "config")
}
func (k *KConf) AddContext(name string, context *clientcmdapi.Context) string {
	if k.hasContext(context) {
		return ""
	}
	name, _ = k.rename(name, "context")
	k.Config.Contexts[name] = context
	return name
}
func (k *KConf) hasContext(context *clientcmdapi.Context) bool {
	var foundContext bool
	for _, ctx := range k.Contexts {
		if reflect.DeepEqual(ctx, context) == true {
			foundContext = true
			break
		}
	}
	return foundContext
}
func (k *KConf) AddCluster(name string, cluster *clientcmdapi.Cluster) string {
	if k.hasCluster(cluster) {
		return ""
	}
	name, _ = k.rename(name, "cluster")
	k.Config.Clusters[name] = cluster
	return name
}
func (k *KConf) hasCluster(cluster *clientcmdapi.Cluster) bool {
	var foundCluster bool
	for _, cls := range k.Clusters {
		if reflect.DeepEqual(cls, cluster) == true {
			foundCluster = true
			break
		}
	}
	return foundCluster
}
func (k *KConf) AddUser(name string, user *clientcmdapi.AuthInfo) string {
	if k.hasUser(user) {
		return ""
	}
	name, _ = k.rename(name, "user")
	k.Config.AuthInfos[name] = user
	return name
}