mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 05:01:46 +00:00
Do not use namespace in url paths pre v1beta3 from client
This commit is contained in:
@@ -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").
|
||||
|
Reference in New Issue
Block a user