mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Remove use of (Label|Field)SelectorParam
This commit is contained in:
parent
b516a521b1
commit
b6d9815b95
@ -58,6 +58,7 @@ func (m *Helper) Get(namespace, name string, export bool) (runtime.Object, error
|
|||||||
Resource(m.Resource).
|
Resource(m.Resource).
|
||||||
Name(name)
|
Name(name)
|
||||||
if export {
|
if export {
|
||||||
|
// TODO: I should be part of GetOptions
|
||||||
req.Param("export", strconv.FormatBool(export))
|
req.Param("export", strconv.FormatBool(export))
|
||||||
}
|
}
|
||||||
return req.Do().Get()
|
return req.Do().Get()
|
||||||
@ -68,8 +69,11 @@ func (m *Helper) List(namespace, apiVersion string, selector labels.Selector, ex
|
|||||||
req := m.RESTClient.Get().
|
req := m.RESTClient.Get().
|
||||||
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
||||||
Resource(m.Resource).
|
Resource(m.Resource).
|
||||||
LabelsSelectorParam(selector)
|
VersionedParams(&metav1.ListOptions{
|
||||||
|
LabelSelector: selector.String(),
|
||||||
|
}, metav1.ParameterCodec)
|
||||||
if export {
|
if export {
|
||||||
|
// TODO: I should be part of ListOptions
|
||||||
req.Param("export", strconv.FormatBool(export))
|
req.Param("export", strconv.FormatBool(export))
|
||||||
}
|
}
|
||||||
return req.Do().Get()
|
return req.Do().Get()
|
||||||
@ -79,9 +83,11 @@ func (m *Helper) Watch(namespace, resourceVersion, apiVersion string, labelSelec
|
|||||||
return m.RESTClient.Get().
|
return m.RESTClient.Get().
|
||||||
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
||||||
Resource(m.Resource).
|
Resource(m.Resource).
|
||||||
Param("resourceVersion", resourceVersion).
|
VersionedParams(&metav1.ListOptions{
|
||||||
Param("watch", "true").
|
ResourceVersion: resourceVersion,
|
||||||
LabelsSelectorParam(labelSelector).
|
Watch: true,
|
||||||
|
LabelSelector: labelSelector.String(),
|
||||||
|
}, metav1.ParameterCodec).
|
||||||
Watch()
|
Watch()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +95,11 @@ func (m *Helper) WatchSingle(namespace, name, resourceVersion string) (watch.Int
|
|||||||
return m.RESTClient.Get().
|
return m.RESTClient.Get().
|
||||||
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
||||||
Resource(m.Resource).
|
Resource(m.Resource).
|
||||||
Param("resourceVersion", resourceVersion).
|
VersionedParams(&metav1.ListOptions{
|
||||||
Param("watch", "true").
|
ResourceVersion: resourceVersion,
|
||||||
FieldsSelectorParam(fields.OneTermEqualSelector("metadata.name", name)).
|
Watch: true,
|
||||||
|
FieldSelector: fields.OneTermEqualSelector("metadata.name", name).String(),
|
||||||
|
}, metav1.ParameterCodec).
|
||||||
Watch()
|
Watch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,21 +58,21 @@ type Getter interface {
|
|||||||
// NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
|
// NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
|
||||||
func NewListWatchFromClient(c Getter, resource string, namespace string, fieldSelector fields.Selector) *ListWatch {
|
func NewListWatchFromClient(c Getter, resource string, namespace string, fieldSelector fields.Selector) *ListWatch {
|
||||||
listFunc := func(options metav1.ListOptions) (runtime.Object, error) {
|
listFunc := func(options metav1.ListOptions) (runtime.Object, error) {
|
||||||
|
options.FieldSelector = fieldSelector.String()
|
||||||
return c.Get().
|
return c.Get().
|
||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Resource(resource).
|
Resource(resource).
|
||||||
VersionedParams(&options, metav1.ParameterCodec).
|
VersionedParams(&options, metav1.ParameterCodec).
|
||||||
FieldsSelectorParam(fieldSelector).
|
|
||||||
Do().
|
Do().
|
||||||
Get()
|
Get()
|
||||||
}
|
}
|
||||||
watchFunc := func(options metav1.ListOptions) (watch.Interface, error) {
|
watchFunc := func(options metav1.ListOptions) (watch.Interface, error) {
|
||||||
options.Watch = true
|
options.Watch = true
|
||||||
|
options.FieldSelector = fieldSelector.String()
|
||||||
return c.Get().
|
return c.Get().
|
||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Resource(resource).
|
Resource(resource).
|
||||||
VersionedParams(&options, metav1.ParameterCodec).
|
VersionedParams(&options, metav1.ParameterCodec).
|
||||||
FieldsSelectorParam(fieldSelector).
|
|
||||||
Watch()
|
Watch()
|
||||||
}
|
}
|
||||||
return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
|
return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
|
||||||
|
@ -16,6 +16,7 @@ go_library(
|
|||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
@ -180,7 +181,9 @@ func (m *rootScopedMetrics) GetForObjects(groupKind schema.GroupKind, selector l
|
|||||||
Resource(resourceName).
|
Resource(resourceName).
|
||||||
Name(v1alpha1.AllObjects).
|
Name(v1alpha1.AllObjects).
|
||||||
SubResource(metricName).
|
SubResource(metricName).
|
||||||
LabelsSelectorParam(selector).
|
VersionedParams(&metav1.ListOptions{
|
||||||
|
LabelSelector: selector.String(),
|
||||||
|
}, metav1.ParameterCodec).
|
||||||
Do().
|
Do().
|
||||||
Into(res)
|
Into(res)
|
||||||
|
|
||||||
@ -234,7 +237,9 @@ func (m *namespacedMetrics) GetForObjects(groupKind schema.GroupKind, selector l
|
|||||||
Namespace(m.namespace).
|
Namespace(m.namespace).
|
||||||
Name(v1alpha1.AllObjects).
|
Name(v1alpha1.AllObjects).
|
||||||
SubResource(metricName).
|
SubResource(metricName).
|
||||||
LabelsSelectorParam(selector).
|
VersionedParams(&metav1.ListOptions{
|
||||||
|
LabelSelector: selector.String(),
|
||||||
|
}, metav1.ParameterCodec).
|
||||||
Do().
|
Do().
|
||||||
Into(res)
|
Into(res)
|
||||||
|
|
||||||
|
@ -523,9 +523,11 @@ func TestSingleWatch(t *testing.T) {
|
|||||||
w, err := client.Core().RESTClient().Get().
|
w, err := client.Core().RESTClient().Get().
|
||||||
Namespace(ns.Name).
|
Namespace(ns.Name).
|
||||||
Resource("events").
|
Resource("events").
|
||||||
Param("resourceVersion", rv1).
|
VersionedParams(&metav1.ListOptions{
|
||||||
Param("watch", "true").
|
ResourceVersion: rv1,
|
||||||
FieldsSelectorParam(fields.OneTermEqualSelector("metadata.name", "event-9")).
|
Watch: true,
|
||||||
|
FieldSelector: fields.OneTermEqualSelector("metadata.name", "event-9").String(),
|
||||||
|
}, metav1.ParameterCodec).
|
||||||
Watch()
|
Watch()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user