Do not use namespace in url paths pre v1beta3 from client

This commit is contained in:
derekwaynecarr
2014-12-19 16:32:42 -05:00
parent 5807b3d6bc
commit abb6632d75
10 changed files with 109 additions and 42 deletions

View File

@@ -36,6 +36,10 @@ import (
type RESTClient struct {
baseURL *url.URL
// namespaceInPath controls if URLs should encode the namespace as path param instead of query param
// needed for backward compatibility
namespaceInPath bool
// Codec is the encoding and decoding scheme that applies to a particular set of
// REST resources.
Codec runtime.Codec
@@ -56,7 +60,7 @@ type RESTClient struct {
// NewRESTClient creates a new RESTClient. This client performs generic REST functions
// such as Get, Put, Post, and Delete on specified paths. Codec controls encoding and
// decoding of responses from the server.
func NewRESTClient(baseURL *url.URL, c runtime.Codec) *RESTClient {
func NewRESTClient(baseURL *url.URL, c runtime.Codec, namespaceInPath bool) *RESTClient {
base := *baseURL
if !strings.HasSuffix(base.Path, "/") {
base.Path += "/"
@@ -68,6 +72,8 @@ func NewRESTClient(baseURL *url.URL, c runtime.Codec) *RESTClient {
baseURL: &base,
Codec: c,
namespaceInPath: namespaceInPath,
// Make asynchronous requests by default
Sync: false,
@@ -98,7 +104,7 @@ func (c *RESTClient) Verb(verb string) *Request {
if poller == nil {
poller = c.DefaultPoll
}
return NewRequest(c.Client, verb, c.baseURL, c.Codec).Poller(poller).Sync(c.Sync).Timeout(c.Timeout)
return NewRequest(c.Client, verb, c.baseURL, c.Codec, c.namespaceInPath).Poller(poller).Sync(c.Sync).Timeout(c.Timeout)
}
// Post begins a POST request. Short for c.Verb("POST").