mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 14:11:14 +00:00
Implement required sync changes everywhere.
Make requests sync by default, so that usage of them doesn't have to change.
This commit is contained in:
@@ -43,9 +43,11 @@ import (
|
||||
// Begin a request with a verb (GET, POST, PUT, DELETE)
|
||||
func (c *Client) Verb(verb string) *Request {
|
||||
return &Request{
|
||||
verb: verb,
|
||||
c: c,
|
||||
path: "/api/v1beta1",
|
||||
verb: verb,
|
||||
c: c,
|
||||
path: "/api/v1beta1",
|
||||
sync: true,
|
||||
timeout: 10 * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +82,7 @@ type Request struct {
|
||||
body io.Reader
|
||||
selector labels.Selector
|
||||
timeout time.Duration
|
||||
sync bool
|
||||
}
|
||||
|
||||
// Append an item to the request path. You must call Path at least once.
|
||||
@@ -91,6 +94,15 @@ func (r *Request) Path(item string) *Request {
|
||||
return r
|
||||
}
|
||||
|
||||
// Set sync/async call status.
|
||||
func (r *Request) Sync(sync bool) *Request {
|
||||
if r.err != nil {
|
||||
return r
|
||||
}
|
||||
r.sync = sync
|
||||
return r
|
||||
}
|
||||
|
||||
// Overwrite an existing path with the path parameter.
|
||||
func (r *Request) AbsPath(path string) *Request {
|
||||
if r.err != nil {
|
||||
@@ -168,8 +180,11 @@ func (r *Request) Do() Result {
|
||||
if r.selector != nil {
|
||||
query.Add("labels", r.selector.String())
|
||||
}
|
||||
if r.timeout != 0 {
|
||||
query.Add("timeout", r.timeout.String())
|
||||
if r.sync {
|
||||
query.Add("sync", "true")
|
||||
if r.timeout != 0 {
|
||||
query.Add("timeout", r.timeout.String())
|
||||
}
|
||||
}
|
||||
finalUrl += "?" + query.Encode()
|
||||
req, err := http.NewRequest(r.verb, finalUrl, r.body)
|
||||
|
Reference in New Issue
Block a user