From 4dc1d36218fd1855d30c677cd6df3484f88f2b95 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 17 Mar 2022 10:21:30 +0100 Subject: [PATCH] cleanup: reduce complexity of main() Move the printing of the version and other information to its own function. This reduces the complexity enough so that golang-ci does not complain about it anymore. Signed-off-by: Niels de Vos --- cmd/cephcsi.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/cephcsi.go b/cmd/cephcsi.go index f419790b0..5b77ca662 100644 --- a/cmd/cephcsi.go +++ b/cmd/cephcsi.go @@ -156,16 +156,20 @@ func getDriverName() string { } } +func printVersion() { + fmt.Println("Cephcsi Version:", util.DriverVersion) + fmt.Println("Git Commit:", util.GitCommit) + fmt.Println("Go Version:", runtime.Version()) + fmt.Println("Compiler:", runtime.Compiler) + fmt.Printf("Platform: %s/%s\n", runtime.GOOS, runtime.GOARCH) + if kv, err := util.GetKernelVersion(); err == nil { + fmt.Println("Kernel:", kv) + } +} + func main() { if conf.Version { - fmt.Println("Cephcsi Version:", util.DriverVersion) - fmt.Println("Git Commit:", util.GitCommit) - fmt.Println("Go Version:", runtime.Version()) - fmt.Println("Compiler:", runtime.Compiler) - fmt.Printf("Platform: %s/%s\n", runtime.GOOS, runtime.GOARCH) - if kv, err := util.GetKernelVersion(); err == nil { - fmt.Println("Kernel:", kv) - } + printVersion() os.Exit(0) } log.DefaultLog("Driver version: %s and Git version: %s", util.DriverVersion, util.GitCommit)