internal/controller/issuerconfig: add missing invalid kubeconfig test?

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
Andrew Keesler 2020-08-27 10:43:13 -04:00
parent d240796110
commit 8ddc1a1e92
No known key found for this signature in database
GPG Key ID: 27CE0444346F9413
2 changed files with 25 additions and 1 deletions

View File

@ -94,7 +94,11 @@ func (c *publisherController) Sync(ctx controller.Context) error {
return nil
}
config, _ := clientcmd.Load([]byte(kubeConfig))
config, err := clientcmd.Load([]byte(kubeConfig))
if err != nil {
klog.InfoS("could not load kubeconfig configmap key")
return nil
}
var certificateAuthorityData, server string
for _, v := range config.Clusters {

View File

@ -436,6 +436,26 @@ func TestSync(t *testing.T) {
r.Empty(pinnipedAPIClient.Actions())
})
})
when("the ConfigMap does not have a valid kubeconfig", func() {
it.Before(func() {
clusterInfoConfigMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{Name: "cluster-info", Namespace: "kube-public"},
Data: map[string]string{
"kubeconfig": "this is an invalid kubeconfig",
},
}
err := kubeInformerClient.Tracker().Add(clusterInfoConfigMap)
r.NoError(err)
})
it("keeps waiting for it to be properly formatted", func() {
startInformersAndController()
err := controller.TestSync(t, subject, *syncContext)
r.NoError(err)
r.Empty(pinnipedAPIClient.Actions())
})
})
})
when("there is not a cluster-info ConfigMap in the kube-public namespace", func() {