mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-03 08:36:53 +00:00
client-go: GetOptions for dynamic client
Kubernetes-commit: 30668b24fbd92e7ab532471f9518ba7b7ef66dcf
This commit is contained in:
parent
5c16341058
commit
92eadecb13
@ -126,11 +126,16 @@ func (rc *ResourceClient) List(opts metav1.ListOptions) (runtime.Object, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get gets the resource with the specified name.
|
// Get gets the resource with the specified name.
|
||||||
func (rc *ResourceClient) Get(name string) (*unstructured.Unstructured, error) {
|
func (rc *ResourceClient) Get(name string, opts metav1.GetOptions) (*unstructured.Unstructured, error) {
|
||||||
|
parameterEncoder := rc.parameterCodec
|
||||||
|
if parameterEncoder == nil {
|
||||||
|
parameterEncoder = defaultParameterEncoder
|
||||||
|
}
|
||||||
result := new(unstructured.Unstructured)
|
result := new(unstructured.Unstructured)
|
||||||
err := rc.cl.Get().
|
err := rc.cl.Get().
|
||||||
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
|
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
|
||||||
Resource(rc.resource.Name).
|
Resource(rc.resource.Name).
|
||||||
|
VersionedParams(&opts, parameterEncoder).
|
||||||
Name(name).
|
Name(name).
|
||||||
Do().
|
Do().
|
||||||
Into(result)
|
Into(result)
|
||||||
|
@ -191,7 +191,7 @@ func TestGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer srv.Close()
|
defer srv.Close()
|
||||||
|
|
||||||
got, err := cl.Resource(resource, tc.namespace).Get(tc.name)
|
got, err := cl.Resource(resource, tc.namespace).Get(tc.name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error when getting %q: %v", tc.name, err)
|
t.Errorf("unexpected error when getting %q: %v", tc.name, err)
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user