util: use local FatalLog() for NewK8sClient() instead of klog

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-08-07 10:18:00 +02:00 committed by mergify[bot]
parent 9d4020d255
commit eaea18df0f

View File

@ -22,7 +22,6 @@ import (
k8s "k8s.io/client-go/kubernetes" k8s "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
klog "k8s.io/klog/v2"
) )
// NewK8sClient create kubernetes client. // NewK8sClient create kubernetes client.
@ -33,20 +32,17 @@ func NewK8sClient() *k8s.Clientset {
if cPath != "" { if cPath != "" {
cfg, err = clientcmd.BuildConfigFromFlags("", cPath) cfg, err = clientcmd.BuildConfigFromFlags("", cPath)
if err != nil { if err != nil {
klog.Errorf("Failed to get cluster config with error: %v\n", err) FatalLog("Failed to get cluster config with error: %v\n", err)
os.Exit(1)
} }
} else { } else {
cfg, err = rest.InClusterConfig() cfg, err = rest.InClusterConfig()
if err != nil { if err != nil {
klog.Errorf("Failed to get cluster config with error: %v\n", err) FatalLog("Failed to get cluster config with error: %v\n", err)
os.Exit(1)
} }
} }
client, err := k8s.NewForConfig(cfg) client, err := k8s.NewForConfig(cfg)
if err != nil { if err != nil {
klog.Errorf("Failed to create client with error: %v\n", err) FatalLog("Failed to create client with error: %v\n", err)
os.Exit(1)
} }
return client return client
} }