Remove extra output lines after the version

Some commands, like crio and runc, dump extra line noise
after the --version even though they have a long version.
pull/12085/head
Anders F Björklund 2021-08-01 10:12:15 +02:00
parent 46c3797169
commit 4f6ee47f28
1 changed files with 4 additions and 1 deletions

View File

@ -69,7 +69,10 @@ var versionCmd = &cobra.Command{
klog.Warningf("error getting %s's version: %v", k, err)
data[k] = "error"
} else {
data[k] = strings.TrimSpace(rr.Stdout.String())
version := rr.Stdout.String()
// remove extra lines after the version
version = strings.Split(version, "\n")[0]
data[k] = strings.TrimSpace(version)
}
}