prow/kube/client.go
func NewClientInCluster(namespace string) (*Client, error) {
	tokenFile := "/var/run/secrets/kubernetes.io/serviceaccount/token"
	token, err := ioutil.ReadFile(tokenFile)
	if err != nil {
		return nil, err
	}

	rootCAFile := "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
	certData, err := ioutil.ReadFile(rootCAFile)
	if err != nil {
		return nil, err
	}

	cp := x509.NewCertPool()
	cp.AppendCertsFromPEM(certData)

	tr := &http.Transport{
		TLSClientConfig: &tls.Config{
			MinVersion: tls.VersionTLS12,
			RootCAs:    cp,
		},
	}
	return &Client{
		logger:    logrus.WithField("client", "kube"),
		baseURL:   inClusterBaseURL,
		client:    &http.Client{Transport: tr, Timeout: requestTimeout},
		token:     string(token),
		namespace: namespace,
	}, nil
}
func NewClientInCluster(namespace string) (*Client, error) {
	tokenFile := "/var/run/secrets/kubernetes.io/serviceaccount/token"
	token, err := ioutil.ReadFile(tokenFile)
	if err != nil {
		return nil, err
	}

	rootCAFile := "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
	certData, err := ioutil.ReadFile(rootCAFile)
	if err != nil {
		return nil, err
	}

	cp := x509.NewCertPool()
	cp.AppendCertsFromPEM(certData)

	tr := &http.Transport{
		TLSClientConfig: &tls.Config{
			MinVersion: tls.VersionTLS12,
			RootCAs:    cp,
		},
	}
	return &Client{
		logger:    logrus.WithField("client", "kube"),
		baseURL:   inClusterBaseURL,
		client:    &http.Client{Transport: tr, Timeout: requestTimeout},
		token:     string(token),
		namespace: namespace,
	}, nil
}
func NewClientInCluster ( namespace string ) ( * Client , error ) { tokenFile := " " token , err := ioutil . ReadFile ( tokenFile ) if err != nil { return nil , err } rootCAFile := " " certData , err := ioutil . ReadFile ( rootCAFile ) if err != nil { return nil , err } cp := x509 . NewCertPool ( ) cp . AppendCertsFromPEM ( certData ) tr := & http . Transport { TLSClientConfig : & tls . Config { MinVersion : tls . VersionTLS12 , RootCAs : cp , } , } return & Client { logger : logrus . WithField ( " " , " " ) , baseURL : inClusterBaseURL , client : & http . Client { Transport : tr , Timeout : requestTimeout } , token : string ( token ) , namespace : namespace , } , nil }
// NewClientInCluster creates a Client that works from within a pod.
NewClientInCluster creates a Client that works from within a pod .