Ejemplo n.º 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
}
Ejemplo n.º 2
0
// 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
}
Ejemplo n.º 3
0
func (u *defaultUpgrader) upgrade(req *client.Request, config *client.Config) (httpstream.Connection, error) {
	return req.Upgrade(config, spdy.NewRoundTripper)
}