mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
util: use local FatalLog() for NewK8sClient() instead of klog
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
9d4020d255
commit
eaea18df0f
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user