Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clients/dynamic/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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,
Expand Down
15 changes: 7 additions & 8 deletions clients/rancher/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -283,19 +282,19 @@ 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
}
return dynamic, nil
}

// 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()
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/clusters/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/kubectl/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
Loading