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
8 changes: 4 additions & 4 deletions clients/rancher/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3"
v1 "github.com/rancher/shepherd/clients/rancher/v1"

rancherDynamic "github.com/rancher/shepherd/clients/dynamic"
kubeProvisioning "github.com/rancher/shepherd/clients/provisioning"
kubeRKE "github.com/rancher/shepherd/clients/rke"
"github.com/rancher/shepherd/pkg/clientbase"
Expand All @@ -25,7 +26,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 @@ -202,7 +202,7 @@ 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) {
func (c *Client) GetRancherDynamicClient() (*rancherDynamic.Client, error) {
dynamic, err := frameworkDynamic.NewForConfig(c.Session, c.restConfig)
if err != nil {
return nil, err
Expand Down Expand Up @@ -231,7 +231,7 @@ 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) (*rancherDynamic.Client, error) {
restConfig := *c.restConfig
restConfig.Host = fmt.Sprintf("https://%s/k8s/clusters/%s", c.restConfig.Host, clusterID)

Expand All @@ -243,7 +243,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) (*rancherDynamic.Client, error) {
overrides := clientcmd.ConfigOverrides{CurrentContext: context}

rawConfig, err := (*clientConfig).RawConfig()
Expand Down
8 changes: 4 additions & 4 deletions extensions/codecoverage/codecoverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

apiv1 "github.com/rancher/rancher/pkg/apis/provisioning.cattle.io/v1"
rancherDynamic "github.com/rancher/shepherd/clients/dynamic"
"github.com/rancher/shepherd/clients/rancher"
v1 "github.com/rancher/shepherd/clients/rancher/v1"
"github.com/rancher/shepherd/extensions/clusters"
Expand All @@ -17,7 +18,6 @@ import (
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kwait "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/dynamic"
)

var podGroupVersionResource = corev1.SchemeGroupVersion.WithResource("pods")
Expand All @@ -30,7 +30,7 @@ const (
outputDir = "cover"
)

func checkServiceIsRunning(dynamicClient dynamic.Interface) error {
func checkServiceIsRunning(dynamicClient rancherDynamic.Client) error {
return kwait.Poll(500*time.Millisecond, 2*time.Minute, func() (done bool, err error) {
_, err = dynamicClient.Resource(podGroupVersionResource).Namespace(cattleSystemNameSpace).List(context.Background(), metav1.ListOptions{})
if k8sErrors.IsInternalError(err) || k8sErrors.IsServiceUnavailable(err) {
Expand Down Expand Up @@ -120,7 +120,7 @@ func KillRancherTestServicesRetrieveCoverage(client *rancher.Client) error {
return err
}

err = checkServiceIsRunning(dynamicClient)
err = checkServiceIsRunning(*dynamicClient)
if err != nil {
return err
}
Expand Down Expand Up @@ -169,7 +169,7 @@ func KillAgentTestServicesRetrieveCoverage(client *rancher.Client) error {
return err
}

err = checkServiceIsRunning(dynamicClient)
err = checkServiceIsRunning(*dynamicClient)
if err != nil {
return err
}
Expand Down