mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-29 21:29:24 +00:00
Use VersionedParams in "extensions" client.
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package unversioned
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
@@ -97,8 +98,7 @@ func (c *daemonSets) Watch(label labels.Selector, field fields.Selector, opts un
|
||||
Prefix("watch").
|
||||
Namespace(c.ns).
|
||||
Resource("daemonsets").
|
||||
Param("resourceVersion", opts.ResourceVersion).
|
||||
TimeoutSeconds(TimeoutFromListOptions(opts)).
|
||||
VersionedParams(&opts, api.Scheme).
|
||||
LabelsSelectorParam(label).
|
||||
FieldsSelectorParam(field).
|
||||
Watch()
|
||||
|
||||
@@ -107,8 +107,7 @@ func (c *deployments) Watch(label labels.Selector, field fields.Selector, opts u
|
||||
Prefix("watch").
|
||||
Namespace(c.ns).
|
||||
Resource("deployments").
|
||||
Param("resourceVersion", opts.ResourceVersion).
|
||||
TimeoutSeconds(TimeoutFromListOptions(opts)).
|
||||
VersionedParams(&opts, api.Scheme).
|
||||
LabelsSelectorParam(label).
|
||||
FieldsSelectorParam(field).
|
||||
Watch()
|
||||
|
||||
@@ -568,12 +568,3 @@ func DefaultKubernetesUserAgent() string {
|
||||
version = seg[0]
|
||||
return fmt.Sprintf("%s/%s (%s/%s) kubernetes/%s", path.Base(os.Args[0]), version, gruntime.GOOS, gruntime.GOARCH, commit)
|
||||
}
|
||||
|
||||
// TimeoutFromListOptions returns timeout to be set via TimeoutSeconds() method
|
||||
// based on given options.
|
||||
func TimeoutFromListOptions(options unversioned.ListOptions) time.Duration {
|
||||
if options.TimeoutSeconds != nil {
|
||||
return time.Duration(*options.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -109,8 +109,7 @@ func (c *horizontalPodAutoscalers) Watch(label labels.Selector, field fields.Sel
|
||||
Prefix("watch").
|
||||
Namespace(c.ns).
|
||||
Resource("horizontalPodAutoscalers").
|
||||
Param("resourceVersion", opts.ResourceVersion).
|
||||
TimeoutSeconds(TimeoutFromListOptions(opts)).
|
||||
VersionedParams(&opts, api.Scheme).
|
||||
LabelsSelectorParam(label).
|
||||
FieldsSelectorParam(field).
|
||||
Watch()
|
||||
|
||||
@@ -99,8 +99,7 @@ func (c *ingress) Watch(label labels.Selector, field fields.Selector, opts unver
|
||||
Prefix("watch").
|
||||
Namespace(c.ns).
|
||||
Resource("ingresses").
|
||||
Param("resourceVersion", opts.ResourceVersion).
|
||||
TimeoutSeconds(TimeoutFromListOptions(opts)).
|
||||
VersionedParams(&opts, api.Scheme).
|
||||
LabelsSelectorParam(label).
|
||||
FieldsSelectorParam(field).
|
||||
Watch()
|
||||
|
||||
@@ -103,8 +103,7 @@ func (c *jobs) Watch(label labels.Selector, field fields.Selector, opts unversio
|
||||
Prefix("watch").
|
||||
Namespace(c.ns).
|
||||
Resource("jobs").
|
||||
Param("resourceVersion", opts.ResourceVersion).
|
||||
TimeoutSeconds(TimeoutFromListOptions(opts)).
|
||||
VersionedParams(&opts, api.Scheme).
|
||||
LabelsSelectorParam(label).
|
||||
FieldsSelectorParam(field).
|
||||
Watch()
|
||||
|
||||
@@ -464,19 +464,6 @@ func (r *Request) Timeout(d time.Duration) *Request {
|
||||
return r
|
||||
}
|
||||
|
||||
// Timeout makes the request use the given duration as a timeout. Sets the "timeoutSeconds"
|
||||
// parameter.
|
||||
func (r *Request) TimeoutSeconds(d time.Duration) *Request {
|
||||
if r.err != nil {
|
||||
return r
|
||||
}
|
||||
if d != 0 {
|
||||
timeout := int64(d.Seconds())
|
||||
r.Param("timeoutSeconds", strconv.FormatInt(timeout, 10))
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Body makes the request use obj as the body. Optional.
|
||||
// If obj is a string, try to read a file of that name.
|
||||
// If obj is a []byte, send it directly.
|
||||
|
||||
@@ -176,16 +176,6 @@ func TestRequestParam(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTimeoutSeconds(t *testing.T) {
|
||||
r := &Request{}
|
||||
r.TimeoutSeconds(time.Duration(5 * time.Second))
|
||||
if !reflect.DeepEqual(r.params, url.Values{
|
||||
"timeoutSeconds": []string{"5"},
|
||||
}) {
|
||||
t.Errorf("invalid timeoutSeconds parameter: %#v", r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestVersionedParams(t *testing.T) {
|
||||
r := (&Request{apiVersion: "v1"}).Param("foo", "a")
|
||||
if !reflect.DeepEqual(r.params, url.Values{"foo": []string{"a"}}) {
|
||||
|
||||
Reference in New Issue
Block a user