func CreateConfig(namespace, userName string, clientCfg *restclient.Config) (*clientcmdapi.Config, error) {
	clusterNick, err := getClusterNicknameFromConfig(clientCfg)
	if err != nil {
		return nil, err
	}

	contextNick, err := getContextNicknameFromConfig(namespace, userName, clientCfg)
	if err != nil {
		return nil, err
	}

	config := clientcmdapi.NewConfig()

	credentials := clientcmdapi.NewAuthInfo()
	credentials.Token = clientCfg.BearerToken
	credentials.ClientCertificate = clientCfg.TLSClientConfig.CertFile
	if len(credentials.ClientCertificate) == 0 {
		credentials.ClientCertificateData = clientCfg.TLSClientConfig.CertData
	}
	credentials.ClientKey = clientCfg.TLSClientConfig.KeyFile
	if len(credentials.ClientKey) == 0 {
		credentials.ClientKeyData = clientCfg.TLSClientConfig.KeyData
	}
	config.AuthInfos[userName] = credentials

	cluster := clientcmdapi.NewCluster()
	cluster.Server = clientCfg.Host
	cluster.CertificateAuthority = clientCfg.CAFile
	if len(cluster.CertificateAuthority) == 0 {
		cluster.CertificateAuthorityData = clientCfg.CAData
	}
	cluster.InsecureSkipTLSVerify = clientCfg.Insecure
	config.Clusters[clusterNick] = cluster

	context := clientcmdapi.NewContext()
	context.Cluster = clusterNick
	context.AuthInfo = userName
	context.Namespace = namespace
	config.Contexts[contextNick] = context
	config.CurrentContext = contextNick

	return config, nil
}
// CreateConfig takes a clientCfg and builds a config (kubeconfig style) from it.
CreateConfig takes a clientCfg and builds a config (kubeconfig style) from it.
// CreateConfig takes a clientCfg and builds a config ( kubeconfig style ) from it .
func CreateConfig(namespace, userName string, clientCfg *restclient.Config) (*clientcmdapi.Config, error) {
	clusterNick, err := getClusterNicknameFromConfig(clientCfg)
	if err != nil {
		return nil, err
	}
	contextNick, err := getContextNicknameFromConfig(namespace, userName, clientCfg)
	if err != nil {
		return nil, err
	}
	config := clientcmdapi.NewConfig()
	credentials := clientcmdapi.NewAuthInfo()
	credentials.Token = clientCfg.BearerToken
	credentials.ClientCertificate = clientCfg.TLSClientConfig.CertFile
	if len(credentials.ClientCertificate) == 0 {
		credentials.ClientCertificateData = clientCfg.TLSClientConfig.CertData
	}
	credentials.ClientKey = clientCfg.TLSClientConfig.KeyFile
	if len(credentials.ClientKey) == 0 {
		credentials.ClientKeyData = clientCfg.TLSClientConfig.KeyData
	}
	config.AuthInfos[userName] = credentials
	cluster := clientcmdapi.NewCluster()
	cluster.Server = clientCfg.Host
	cluster.CertificateAuthority = clientCfg.CAFile
	if len(cluster.CertificateAuthority) == 0 {
		cluster.CertificateAuthorityData = clientCfg.CAData
	}
	cluster.InsecureSkipTLSVerify = clientCfg.Insecure
	config.Clusters[clusterNick] = cluster
	context := clientcmdapi.NewContext()
	context.Cluster = clusterNick
	context.AuthInfo = userName
	context.Namespace = namespace
	config.Contexts[contextNick] = context
	config.CurrentContext = contextNick
	return config, nil
}
func CreateConfig ( namespace , userName string , clientCfg * restclient . Config ) ( * clientcmdapi . Config , error ) { clusterNick , err := getClusterNicknameFromConfig ( clientCfg ) if err != nil { return nil , err } contextNick , err := getContextNicknameFromConfig ( namespace , userName , clientCfg ) if err != nil { return nil , err } config := clientcmdapi . NewConfig ( ) credentials := clientcmdapi . NewAuthInfo ( ) credentials . Token = clientCfg . BearerToken credentials . ClientCertificate = clientCfg . TLSClientConfig . CertFile if len ( credentials . ClientCertificate ) == 0 { credentials . ClientCertificateData = clientCfg . TLSClientConfig . CertData } credentials . ClientKey = clientCfg . TLSClientConfig . KeyFile if len ( credentials . ClientKey ) == 0 { credentials . ClientKeyData = clientCfg . TLSClientConfig . KeyData } config . AuthInfos [ userName ] = credentials cluster := clientcmdapi . NewCluster ( ) cluster . Server = clientCfg . Host cluster . CertificateAuthority = clientCfg . CAFile if len ( cluster . CertificateAuthority ) == 0 { cluster . CertificateAuthorityData = clientCfg . CAData } cluster . InsecureSkipTLSVerify = clientCfg . Insecure config . Clusters [ clusterNick ] = cluster context := clientcmdapi . NewContext ( ) context . Cluster = clusterNick context . AuthInfo = userName context . Namespace = namespace config . Contexts [ contextNick ] = context config . CurrentContext = contextNick return config , nil }
CreateConfig takes a clientCfg and builds a config (kubeconfig style) from it.
CreateConfig takes a clientCfg and builds a config ( kubeconfig style ) from it .