mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-10 19:38:57 +00:00
[client-go] Add dynamic.Interface
This adds an interface form of dynamic.Client and dynamic.ResourceClient, making those two follow the general client conventions: `Interface` is an interface, and `Client` is the concrete implementation. `ClientPool` retains it's interface status. This allows us to create a fake implemenation of dyanmic.Interface, dynamic.ResourceInterface, and dynamic.ClientPool for testing. Kubernetes-commit: f78d61e7c263392f31560b90c08c57765ceae482
This commit is contained in:
committed by
Kubernetes Publisher
parent
54d90de185
commit
cb42486a30
@@ -28,10 +28,10 @@ import (
|
||||
type ClientPool interface {
|
||||
// ClientForGroupVersionKind returns a client configured for the specified groupVersionResource.
|
||||
// Resource may be empty.
|
||||
ClientForGroupVersionResource(resource schema.GroupVersionResource) (*Client, error)
|
||||
ClientForGroupVersionResource(resource schema.GroupVersionResource) (Interface, error)
|
||||
// ClientForGroupVersionKind returns a client configured for the specified groupVersionKind.
|
||||
// Kind may be empty.
|
||||
ClientForGroupVersionKind(kind schema.GroupVersionKind) (*Client, error)
|
||||
ClientForGroupVersionKind(kind schema.GroupVersionKind) (Interface, error)
|
||||
}
|
||||
|
||||
// APIPathResolverFunc knows how to convert a groupVersion to its API path. The Kind field is
|
||||
@@ -79,7 +79,7 @@ func NewDynamicClientPool(cfg *restclient.Config) ClientPool {
|
||||
|
||||
// ClientForGroupVersionResource uses the provided RESTMapper to identify the appropriate resource. Resource may
|
||||
// be empty. If no matching kind is found the underlying client for that group is still returned.
|
||||
func (c *clientPoolImpl) ClientForGroupVersionResource(resource schema.GroupVersionResource) (*Client, error) {
|
||||
func (c *clientPoolImpl) ClientForGroupVersionResource(resource schema.GroupVersionResource) (Interface, error) {
|
||||
kinds, err := c.mapper.KindsFor(resource)
|
||||
if err != nil {
|
||||
if meta.IsNoMatchError(err) {
|
||||
@@ -92,7 +92,7 @@ func (c *clientPoolImpl) ClientForGroupVersionResource(resource schema.GroupVers
|
||||
|
||||
// ClientForGroupVersion returns a client for the specified groupVersion, creates one if none exists. Kind
|
||||
// in the GroupVersionKind may be empty.
|
||||
func (c *clientPoolImpl) ClientForGroupVersionKind(kind schema.GroupVersionKind) (*Client, error) {
|
||||
func (c *clientPoolImpl) ClientForGroupVersionKind(kind schema.GroupVersionKind) (Interface, error) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
|
Reference in New Issue
Block a user