Skip to content

Commit

Permalink
drop kubeclient struct (#2151)
Browse files Browse the repository at this point in the history
  • Loading branch information
dprotaso authored Jun 10, 2021
1 parent eaa823c commit c96c7be
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions test/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,19 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
k8styped "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"knative.dev/pkg/test/logging"
"knative.dev/pkg/test/spoof"
)

// KubeClient holds instances of interfaces for making requests to kubernetes client.
// Deprecated: use a kubeclient and the helper methods in test.
type KubeClient struct {
kubernetes.Interface
}

// NewSpoofingClient returns a spoofing client to make requests
func NewSpoofingClient(ctx context.Context, client kubernetes.Interface, logf logging.FormatLogger,
domain string, resolvable bool, opts ...spoof.TransportOption) (*spoof.SpoofingClient, error) {
return spoof.New(ctx, client, logf, domain, resolvable, Flags.IngressEndpoint,
Flags.SpoofRequestInterval, Flags.SpoofRequestTimeout, opts...)
}

// NewKubeClient instantiates and returns several clientsets required for making request to the
// kube client specified by the combination of clusterName and configPath. Clients can make requests within namespace.
// Deprecated: use a kubeclient and the helper methods in test.
func NewKubeClient(configPath string, clusterName string) (*KubeClient, error) {
cfg, err := BuildClientConfig(configPath, clusterName)
if err != nil {
return nil, err
}

k, err := kubernetes.NewForConfig(cfg)
if err != nil {
return nil, err
}
return &KubeClient{Interface: k}, nil
}

// BuildClientConfig builds the client config specified by the config path and the cluster name
func BuildClientConfig(kubeConfigPath string, clusterName string) (*rest.Config, error) {
overrides := clientcmd.ConfigOverrides{}
Expand All @@ -74,12 +51,6 @@ func BuildClientConfig(kubeConfigPath string, clusterName string) (*rest.Config,
&overrides).ClientConfig()
}

// UpdateConfigMap updates the config map for specified @name with values
// Deprecated: use UpdateConfigMap
func (client *KubeClient) UpdateConfigMap(ctx context.Context, name string, configName string, values map[string]string) error {
return UpdateConfigMap(ctx, client, name, configName, values)
}

// UpdateConfigMap updates the config map for specified @name with values
func UpdateConfigMap(ctx context.Context, client kubernetes.Interface, name string, configName string, values map[string]string) error {
configMap, err := client.CoreV1().ConfigMaps(name).Get(ctx, configName, metav1.GetOptions{})
Expand All @@ -95,30 +66,12 @@ func UpdateConfigMap(ctx context.Context, client kubernetes.Interface, name stri
return err
}

// GetConfigMap gets the knative serving config map.
// Deprecated: use kubeclient.CoreV1().ConfigMaps(name)
func (client *KubeClient) GetConfigMap(name string) k8styped.ConfigMapInterface {
return client.CoreV1().ConfigMaps(name)
}

// CreatePod will create a Pod
// Deprecated: use CreatePod
func (client *KubeClient) CreatePod(ctx context.Context, pod *corev1.Pod) (*corev1.Pod, error) {
return CreatePod(ctx, client, pod)
}

// CreatePod will create a Pod
func CreatePod(ctx context.Context, client kubernetes.Interface, pod *corev1.Pod) (*corev1.Pod, error) {
pods := client.CoreV1().Pods(pod.GetNamespace())
return pods.Create(ctx, pod, metav1.CreateOptions{})
}

// PodLogs returns Pod logs for given Pod and Container in the namespace
// Deprecated: use PodLogs
func (client *KubeClient) PodLogs(ctx context.Context, podName, containerName, namespace string) ([]byte, error) {
return PodLogs(ctx, client, podName, containerName, namespace)
}

// PodLogs returns Pod logs for given Pod and Container in the namespace
func PodLogs(ctx context.Context, client kubernetes.Interface, podName, containerName, namespace string) ([]byte, error) {
pods := client.CoreV1().Pods(namespace)
Expand Down

0 comments on commit c96c7be

Please sign in to comment.