mirror of
https://github.com/rancher/norman.git
synced 2025-08-31 14:51:57 +00:00
Add ListNamespaced method for ObjectClient
This commit is contained in:
@@ -91,6 +91,7 @@ type {{.schema.CodeName}}Interface interface {
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*{{.schema.CodeName}}List, error)
|
||||
ListNamespaced(namespace string, opts metav1.ListOptions) (*{{.schema.CodeName}}List, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() {{.schema.CodeName}}Controller
|
||||
@@ -279,6 +280,11 @@ func (s *{{.schema.ID}}Client) List(opts metav1.ListOptions) (*{{.schema.CodeNam
|
||||
return obj.(*{{.schema.CodeName}}List), err
|
||||
}
|
||||
|
||||
func (s *{{.schema.ID}}Client) ListNamespaced(namespace string, opts metav1.ListOptions) (*{{.schema.CodeName}}List, error) {
|
||||
obj, err := s.objectClient.ListNamespaced(namespace, opts)
|
||||
return obj.(*{{.schema.CodeName}}List), err
|
||||
}
|
||||
|
||||
func (s *{{.schema.ID}}Client) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
@@ -48,6 +48,7 @@ type GenericClient interface {
|
||||
DeleteNamespaced(namespace, name string, opts *metav1.DeleteOptions) error
|
||||
Delete(name string, opts *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (runtime.Object, error)
|
||||
ListNamespaced(namespace string, opts metav1.ListOptions) (runtime.Object, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOptions *metav1.DeleteOptions, listOptions metav1.ListOptions) error
|
||||
Patch(name string, o runtime.Object, patchType types.PatchType, data []byte, subresources ...string) (runtime.Object, error)
|
||||
@@ -228,6 +229,18 @@ func (p *ObjectClient) List(opts metav1.ListOptions) (runtime.Object, error) {
|
||||
Into(result)
|
||||
}
|
||||
|
||||
func (p *ObjectClient) ListNamespaced(namespace string, opts metav1.ListOptions) (runtime.Object, error) {
|
||||
result := p.Factory.List()
|
||||
logrus.Debugf("REST LIST %s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, namespace, p.resource.Name)
|
||||
return result, p.restClient.Get().
|
||||
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||
NamespaceIfScoped(namespace, p.resource.Namespaced).
|
||||
Resource(p.resource.Name).
|
||||
VersionedParams(&opts, metav1.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
}
|
||||
|
||||
func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
restClient := p.restClient
|
||||
if watchClient, ok := restClient.(restwatch.WatchClient); ok {
|
||||
|
Reference in New Issue
Block a user