diff --git a/clients/dynamic/dynamic.go b/clients/dynamic/dynamic.go index b46ec3ec..f2a6f1a5 100644 --- a/clients/dynamic/dynamic.go +++ b/clients/dynamic/dynamic.go @@ -23,7 +23,7 @@ type Client struct { } // NewForConfig creates a new dynamic client or returns an error. -func NewForConfig(ts *session.Session, inConfig *rest.Config) (dynamic.Interface, error) { +func NewForConfig(ts *session.Session, inConfig *rest.Config) (*Client, error) { logrus.Debugf("Dynamic Client Host:%s", inConfig.Host) dynamicClient, err := dynamic.NewForConfig(inConfig) @@ -44,7 +44,7 @@ func NewForConfig(ts *session.Session, inConfig *rest.Config) (dynamic.Interface // Version: "v3", // Resource: "users", // } -func (d *Client) Resource(resource schema.GroupVersionResource) dynamic.NamespaceableResourceInterface { +func (d *Client) Resource(resource schema.GroupVersionResource) *NamespaceableResourceClient { return &NamespaceableResourceClient{ NamespaceableResourceInterface: d.Interface.Resource(resource), ts: d.ts, @@ -59,7 +59,7 @@ type NamespaceableResourceClient struct { } // Namespace returns a dynamic.ResourceInterface that is embedded in ResourceClient, so ultimately its Create is overwritten. -func (d *NamespaceableResourceClient) Namespace(s string) dynamic.ResourceInterface { +func (d *NamespaceableResourceClient) Namespace(s string) *ResourceClient { return &ResourceClient{ ResourceInterface: d.NamespaceableResourceInterface.Namespace(s), ts: d.ts, diff --git a/clients/rancher/client.go b/clients/rancher/client.go index 2e757774..b015b952 100644 --- a/clients/rancher/client.go +++ b/clients/rancher/client.go @@ -11,7 +11,7 @@ import ( "github.com/pkg/errors" "github.com/rancher/norman/httperror" - frameworkDynamic "github.com/rancher/shepherd/clients/dynamic" + shepherdDynamic "github.com/rancher/shepherd/clients/dynamic" "github.com/rancher/shepherd/clients/ec2" "github.com/rancher/shepherd/clients/rancher/catalog" management "github.com/rancher/shepherd/clients/rancher/generated/management/v3" @@ -28,7 +28,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/dynamic" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" ) @@ -254,8 +253,8 @@ func (c *Client) GetClusterCatalogClient(clusterID string) (*catalog.Client, err } // GetRancherDynamicClient is a helper function that instantiates a dynamic client to communicate with the rancher host. -func (c *Client) GetRancherDynamicClient() (dynamic.Interface, error) { - dynamic, err := frameworkDynamic.NewForConfig(c.Session, c.restConfig) +func (c *Client) GetRancherDynamicClient() (*shepherdDynamic.Client, error) { + dynamic, err := shepherdDynamic.NewForConfig(c.Session, c.restConfig) if err != nil { return nil, err } @@ -283,11 +282,11 @@ func (c *Client) GetKubeAPIRKEClient() (*kubeRKE.Client, error) { } // GetDownStreamClusterClient is a helper function that instantiates a dynamic client to communicate with a specific cluster. -func (c *Client) GetDownStreamClusterClient(clusterID string) (dynamic.Interface, error) { +func (c *Client) GetDownStreamClusterClient(clusterID string) (*shepherdDynamic.Client, error) { restConfig := *c.restConfig restConfig.Host = fmt.Sprintf("https://%s/k8s/clusters/%s", c.restConfig.Host, clusterID) - dynamic, err := frameworkDynamic.NewForConfig(c.Session, &restConfig) + dynamic, err := shepherdDynamic.NewForConfig(c.Session, &restConfig) if err != nil { return nil, err } @@ -295,7 +294,7 @@ func (c *Client) GetDownStreamClusterClient(clusterID string) (dynamic.Interface } // SwitchContext is a helper function that changes the current context to `context` and instantiates a dynamic client -func (c *Client) SwitchContext(context string, clientConfig *clientcmd.ClientConfig) (dynamic.Interface, error) { +func (c *Client) SwitchContext(context string, clientConfig *clientcmd.ClientConfig) (*shepherdDynamic.Client, error) { overrides := clientcmd.ConfigOverrides{CurrentContext: context} rawConfig, err := (*clientConfig).RawConfig() @@ -310,7 +309,7 @@ func (c *Client) SwitchContext(context string, clientConfig *clientcmd.ClientCon return nil, err } - dynamic, err := frameworkDynamic.NewForConfig(c.Session, restConfig) + dynamic, err := shepherdDynamic.NewForConfig(c.Session, restConfig) if err != nil { return nil, err } diff --git a/extensions/clusters/import.go b/extensions/clusters/import.go index 1663cbfe..3c4738c6 100644 --- a/extensions/clusters/import.go +++ b/extensions/clusters/import.go @@ -7,7 +7,7 @@ import ( "github.com/rancher/norman/types" apisV1 "github.com/rancher/rancher/pkg/apis/provisioning.cattle.io/v1" - "github.com/rancher/shepherd/clients/dynamic" + shepherdDynamic "github.com/rancher/shepherd/clients/dynamic" "github.com/rancher/shepherd/clients/rancher" management "github.com/rancher/shepherd/clients/rancher/generated/management/v3" ext_unstructured "github.com/rancher/shepherd/extensions/unstructured" @@ -89,7 +89,7 @@ func ImportCluster(client *rancher.Client, cluster *apisV1.Cluster, rest *rest.C return err } - downClient, err := dynamic.NewForConfig(ts, rest) + downClient, err := shepherdDynamic.NewForConfig(ts, rest) if err != nil { return err } diff --git a/extensions/kubectl/template.go b/extensions/kubectl/template.go index a0f35f43..3e9c0f3b 100644 --- a/extensions/kubectl/template.go +++ b/extensions/kubectl/template.go @@ -11,7 +11,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/rancher/shepherd/clients/dynamic" + shepherdDynamic "github.com/rancher/shepherd/clients/dynamic" "github.com/rancher/shepherd/extensions/unstructured" "github.com/rancher/shepherd/pkg/wait" rbacv1 "k8s.io/api/rbac/v1" @@ -54,7 +54,7 @@ func CreateJobAndRunKubectlCommands(clusterID, jobname string, job *batchv1.Job, ts := client.Session.NewSession() defer ts.Cleanup() - downClient, err := dynamic.NewForConfig(ts, restConfig) + downClient, err := shepherdDynamic.NewForConfig(ts, restConfig) if err != nil { return err }