Fix a bad assumption in library.NewClientConfigWithCertAndKey.

It turns out these fields are not meant to be base64 encoded, even though that's how they are in the kubeconfig.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2020-07-27 07:52:36 -05:00 committed by Ryan Richard
parent 69f766d41d
commit f7b0cf8f8a
1 changed files with 5 additions and 4 deletions

View File

@ -6,7 +6,6 @@ SPDX-License-Identifier: Apache-2.0
package library
import (
"encoding/base64"
"testing"
"github.com/stretchr/testify/require"
@ -29,8 +28,8 @@ func NewClientConfigWithCertAndKey(t *testing.T, cert, key string) *rest.Config
return newClientConfigWithOverrides(t, &clientcmd.ConfigOverrides{
AuthInfo: clientcmdapi.AuthInfo{
ClientCertificateData: []byte(base64.StdEncoding.EncodeToString([]byte(cert))),
ClientKeyData: []byte(base64.StdEncoding.EncodeToString([]byte(key))),
ClientCertificateData: []byte(cert),
ClientKeyData: []byte(key),
},
})
}
@ -54,7 +53,9 @@ func NewClientset(t *testing.T) kubernetes.Interface {
func NewClientsetWithConfig(t *testing.T, config *rest.Config) kubernetes.Interface {
t.Helper()
return kubernetes.NewForConfigOrDie(config)
result, err := kubernetes.NewForConfig(config)
require.NoError(t, err, "unexpected failure from kubernetes.NewForConfig()")
return result
}
func NewPlaceholderNameClientset(t *testing.T) placeholdernameclientset.Interface {