// NewK8sClient gives a k8sClient with the given dependencies.
NewK8sClient gives a k8sClient with the given dependencies.
// NewK8sClient gives a k8sClient with the given dependencies .
func NewK8sClient(namespace, target, kubeconfig string, dryRun bool) (K8sClient, error) {
	var config *rest.Config
	var err error
	if kubeconfig != "" {
		config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
	} else {
		config, err = rest.InClusterConfig()
	}
	if err != nil {
		return nil, err
	}
	config.UserAgent = userAgent()
	config.ContentType = "application/vnd.kubernetes.protobuf"
	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		return nil, err
	}
	tgt, err := makeTarget(clientset, target, namespace)
	if err != nil {
		return nil, err
	}
	return &k8sClient{
		clientset: clientset,
		target:    tgt,
		dryRun:    dryRun,
	}, nil
}
func NewK8sClient ( namespace , target , kubeconfig string , dryRun bool ) ( K8sClient , error ) { var config * rest . Config var err error if kubeconfig != " " { config , err = clientcmd . BuildConfigFromFlags ( " " , kubeconfig ) } else { config , err = rest . InClusterConfig ( ) } if err != nil { return nil , err } config . UserAgent = userAgent ( ) config . ContentType = " " clientset , err := kubernetes . NewForConfig ( config ) if err != nil { return nil , err } tgt , err := makeTarget ( clientset , target , namespace ) if err != nil { return nil , err } return & k8sClient { clientset : clientset , target : tgt , dryRun : dryRun , } , nil }
NewK8sClient gives a k8sClient with the given dependencies.
NewK8sClient gives a k8sClient with the given dependencies .
// Use protobufs for communication with apiserver.