diff --git a/tools/kubernetes.go b/tools/kubernetes.go index 2341e37..1e40d4c 100644 --- a/tools/kubernetes.go +++ b/tools/kubernetes.go @@ -56,12 +56,16 @@ func NewDynamicClient(host string, ca string, cert string, data string) (*dynami } func NewKubernetesService(host string, ca string, cert string, data string) (*KubernetesService, error) { + decodedCa, _ := base64.StdEncoding.DecodeString(ca) + decodedCert, _ := base64.StdEncoding.DecodeString(cert) + decodedKey, _ := base64.StdEncoding.DecodeString(data) + config := &rest.Config{ Host: host, TLSClientConfig: rest.TLSClientConfig{ - CAData: []byte(ca), - CertData: []byte(cert), - KeyData: []byte(data), + CAData: []byte(decodedCa), + CertData: []byte(decodedCert), + KeyData: []byte(decodedKey), }, } @@ -84,38 +88,6 @@ func NewKubernetesService(host string, ca string, cert string, data string) (*Ku }, nil } -func NewRemoteKubernetesService(url string, ca string, cert string, key string) (*KubernetesService, error) { - decodedCa, _ := base64.StdEncoding.DecodeString(ca) - decodedCert, _ := base64.StdEncoding.DecodeString(cert) - decodedKey, _ := base64.StdEncoding.DecodeString(key) - - config := &rest.Config{ - Host: url + ":6443", - TLSClientConfig: rest.TLSClientConfig{ - CAData: decodedCa, - CertData: decodedCert, - KeyData: decodedKey, - }, - } - // Create clientset - clientset, err := kubernetes.NewForConfig(config) - fmt.Println("NewForConfig", clientset, err) - if err != nil { - return nil, errors.New("Error creating Kubernetes client: " + err.Error()) - } - if clientset == nil { - return nil, errors.New("Error creating Kubernetes client: clientset is nil") - } - - return &KubernetesService{ - Set: clientset, - Host: url, - CA: string(decodedCa), - Cert: string(decodedCert), - Data: string(decodedKey), - }, nil -} - func (k *KubernetesService) CreateNamespace(ctx context.Context, ns string) error { // Define the namespace fmt.Println("ExecutionID in CreateNamespace() : ", ns)