mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 04:32:37 +00:00
Making all operations synchronous
This commit is contained in:
@@ -39,7 +39,7 @@ import (
|
||||
|
||||
// specialParams lists parameters that are handled specially and which users of Request
|
||||
// are therefore not allowed to set manually.
|
||||
var specialParams = util.NewStringSet("sync", "timeout")
|
||||
var specialParams = util.NewStringSet("timeout")
|
||||
|
||||
// PollFunc is called when a server operation returns 202 accepted. The name of the
|
||||
// operation is extracted from the response and passed to this function. Return a
|
||||
@@ -107,7 +107,6 @@ type Request struct {
|
||||
resource string
|
||||
resourceName string
|
||||
selector labels.Selector
|
||||
sync bool
|
||||
timeout time.Duration
|
||||
|
||||
// output
|
||||
@@ -177,15 +176,6 @@ func (r *Request) Name(resourceName string) *Request {
|
||||
return r
|
||||
}
|
||||
|
||||
// Sync sets sync/async call status by setting the "sync" parameter to "true"/"false".
|
||||
func (r *Request) Sync(sync bool) *Request {
|
||||
if r.err != nil {
|
||||
return r
|
||||
}
|
||||
r.sync = sync
|
||||
return r
|
||||
}
|
||||
|
||||
// Namespace applies the namespace scope to a request (<resource>/[ns/<namespace>/]<name>)
|
||||
func (r *Request) Namespace(namespace string) *Request {
|
||||
if r.err != nil {
|
||||
@@ -270,7 +260,7 @@ func (r *Request) setParam(paramName, value string) *Request {
|
||||
}
|
||||
|
||||
// Timeout makes the request use the given duration as a timeout. Sets the "timeout"
|
||||
// parameter. Ignored if sync=false.
|
||||
// parameter.
|
||||
func (r *Request) Timeout(d time.Duration) *Request {
|
||||
if r.err != nil {
|
||||
return r
|
||||
@@ -359,13 +349,9 @@ func (r *Request) finalURL() string {
|
||||
query.Add("namespace", r.namespace)
|
||||
}
|
||||
|
||||
// sync and timeout are handled specially here, to allow setting them
|
||||
// in any order.
|
||||
if r.sync {
|
||||
query.Add("sync", "true")
|
||||
if r.timeout != 0 {
|
||||
query.Add("timeout", r.timeout.String())
|
||||
}
|
||||
// timeout is handled specially here.
|
||||
if r.timeout != 0 {
|
||||
query.Add("timeout", r.timeout.String())
|
||||
}
|
||||
finalURL.RawQuery = query.Encode()
|
||||
return finalURL.String()
|
||||
|
Reference in New Issue
Block a user