Export kubernetes client to use externally

image-warning-sha256
Varsha Varadarajan 2019-07-12 13:33:17 -04:00
parent 48f302945b
commit 7e161b4b3e
2 changed files with 7 additions and 7 deletions

View File

@ -53,13 +53,13 @@ type Objects struct {
// Client encapsulates a client for a Kubernetes cluster.
type Client struct {
kubeClient kubernetes.Interface
KubeClient kubernetes.Interface
}
// FetchObjects returns the objects from a Kubernetes cluster.
func (c *Client) FetchObjects() (*Objects, error) {
client := c.kubeClient.CoreV1()
admissionControllerClient := c.kubeClient.AdmissionregistrationV1beta1()
client := c.KubeClient.CoreV1()
admissionControllerClient := c.KubeClient.AdmissionregistrationV1beta1()
opts := metav1.ListOptions{}
objects := &Objects{}
@ -161,7 +161,7 @@ func NewClient(configPath, configContext string) (*Client, error) {
}
return &Client{
kubeClient: client,
KubeClient: client,
}, nil
}
@ -181,6 +181,6 @@ func BuildClient(yaml []byte) (*Client, error) {
}
return &Client{
kubeClient: client,
KubeClient: client,
}, nil
}

View File

@ -27,10 +27,10 @@ import (
func TestFetchObjects(t *testing.T) {
api := &Client{
kubeClient: fake.NewSimpleClientset(),
KubeClient: fake.NewSimpleClientset(),
}
api.kubeClient.CoreV1().Namespaces().Create(&corev1.Namespace{
api.KubeClient.CoreV1().Namespaces().Create(&corev1.Namespace{
TypeMeta: metav1.TypeMeta{Kind: "Namespace", APIVersion: "v1"},
ObjectMeta: metav1.ObjectMeta{
Name: "kube-system",