mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-07 12:11:43 +00:00
Merge pull request #3066 from derekwaynecarr/client_update
Do not use namespace in url paths pre v1beta3 from client
This commit is contained in:
@@ -96,20 +96,23 @@ type Request struct {
|
||||
sync bool
|
||||
timeout time.Duration
|
||||
|
||||
// flag to control how to use namespace in urls
|
||||
namespaceAsPath bool
|
||||
|
||||
// output
|
||||
err error
|
||||
body io.Reader
|
||||
}
|
||||
|
||||
// NewRequest creates a new request with the core attributes.
|
||||
func NewRequest(client HTTPClient, verb string, baseURL *url.URL, codec runtime.Codec) *Request {
|
||||
func NewRequest(client HTTPClient, verb string, baseURL *url.URL, codec runtime.Codec, namespaceAsPath bool) *Request {
|
||||
return &Request{
|
||||
client: client,
|
||||
verb: verb,
|
||||
baseURL: baseURL,
|
||||
codec: codec,
|
||||
|
||||
path: baseURL.Path,
|
||||
client: client,
|
||||
verb: verb,
|
||||
baseURL: baseURL,
|
||||
codec: codec,
|
||||
namespaceAsPath: namespaceAsPath,
|
||||
path: baseURL.Path,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +139,14 @@ func (r *Request) Namespace(namespace string) *Request {
|
||||
if r.err != nil {
|
||||
return r
|
||||
}
|
||||
|
||||
if len(namespace) > 0 {
|
||||
return r.Path("ns").Path(namespace)
|
||||
if r.namespaceAsPath {
|
||||
return r.Path("ns").Path(namespace)
|
||||
} else {
|
||||
return r.setParam("namespace", namespace)
|
||||
}
|
||||
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
Reference in New Issue
Block a user