mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
runc -v: set default for, always show main.version
Apparently not everyone compiles runc via the provided Makefile. For example, one can just run "go build", in which case Version variable is left empty, which leads to: $ ./runc -v runc version spec: 1.0.2-dev go: go1.16.3 Surely, the main problem here is runc was built in a wrong way, but the second problem is such output is very confusing -- it may seem that we have runc 1.0.2. To solve, make sure to _always_ add version (even if empty), and set the default to "unknown". NOTE this does not change anything in case runc is compiled via the Makefile. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -15,9 +15,9 @@ import (
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// version will be populated by the Makefile, read from
|
||||
// VERSION file of the source code.
|
||||
var version = ""
|
||||
// version must be set from the contents of VERSION file by go build's
|
||||
// -X main.version= option in the Makefile.
|
||||
var version = "unknown"
|
||||
|
||||
// gitCommit will be the hash that the binary was built from
|
||||
// and will be populated by the Makefile
|
||||
@@ -55,10 +55,8 @@ func main() {
|
||||
app.Name = "runc"
|
||||
app.Usage = usage
|
||||
|
||||
var v []string
|
||||
if version != "" {
|
||||
v = append(v, version)
|
||||
}
|
||||
v := []string{version}
|
||||
|
||||
if gitCommit != "" {
|
||||
v = append(v, "commit: "+gitCommit)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user