From f9691208d5c2f217779765c757db762d74e214d8 Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Mon, 14 Dec 2020 18:41:11 -0600 Subject: [PATCH] Add library.NewRestConfigFromKubeconfig() test helper. This is extracted from library.NewClientsetForKubeConfig(). It is useful so you can assert properties of the loaded, parsed kubeconfig. Signed-off-by: Matt Moyer --- test/library/client.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/library/client.go b/test/library/client.go index 3593b92e..0c28d6c4 100644 --- a/test/library/client.go +++ b/test/library/client.go @@ -50,7 +50,10 @@ func NewClientset(t *testing.T) kubernetes.Interface { func NewClientsetForKubeConfig(t *testing.T, kubeConfig string) kubernetes.Interface { t.Helper() + return newClientsetWithConfig(t, NewRestConfigFromKubeconfig(t, kubeConfig)) +} +func NewRestConfigFromKubeconfig(t *testing.T, kubeConfig string) *rest.Config { kubeConfigFile, err := ioutil.TempFile("", "pinniped-cli-test-*") require.NoError(t, err) defer os.Remove(kubeConfigFile.Name()) @@ -60,8 +63,7 @@ func NewClientsetForKubeConfig(t *testing.T, kubeConfig string) kubernetes.Inter restConfig, err := clientcmd.BuildConfigFromFlags("", kubeConfigFile.Name()) require.NoError(t, err) - - return newClientsetWithConfig(t, restConfig) + return restConfig } func NewClientsetWithCertAndKey(t *testing.T, clientCertificateData, clientKeyData string) kubernetes.Interface {