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

View File

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