コード例 #1
0
// overrideAuth specifies the token to authenticate the request with.  token == "" is not allowed
func overrideAuth(token *string, req *client.Request) (*client.Request, error) {
	if token != nil {
		if len(*token) == 0 {
			return nil, errors.New("impersonating token may not be empty")
		}

		req.SetHeader("Authorization", fmt.Sprintf("Bearer %s", *token))
	}
	return req, nil
}
コード例 #2
0
ファイル: client.go プロジェクト: ethernetdan/kubernetes
// namespace applies a namespace to the request if the configured
// resource is a namespaced resource. Otherwise, it just returns the
// passed in request.
func (rc *ResourceClient) namespace(req *client.Request) *client.Request {
	if rc.resource.Namespaced {
		return req.Namespace(rc.ns)
	}
	return req
}
コード例 #3
0
ファイル: portforward.go プロジェクト: alena1108/kubernetes
func (u *defaultUpgrader) upgrade(req *client.Request, config *client.Config) (httpstream.Connection, error) {
	return req.Upgrade(config, spdy.NewRoundTripper)
}