linuxkit: move version info to subpackage

Will avoid circular includes when I reference from pkglib too.

Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
Ian Campbell
2017-12-01 13:55:43 +00:00
parent d4451e4652
commit 13adecbc3e
3 changed files with 17 additions and 12 deletions

View File

@@ -7,6 +7,8 @@ import (
"os"
"path/filepath"
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/version"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)
@@ -27,12 +29,6 @@ type PkgConfig struct {
var (
defaultLogFormatter = &log.TextFormatter{}
// Version is the human-readable version
Version = "unknown"
// GitCommit hash, set at compile time
GitCommit = "unknown"
// Config is the global tool configuration
Config = GlobalConfig{}
)
@@ -49,9 +45,9 @@ func (f *infoFormatter) Format(entry *log.Entry) ([]byte, error) {
return defaultLogFormatter.Format(entry)
}
func version() {
fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), Version)
fmt.Printf("commit: %s\n", GitCommit)
func printVersion() {
fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), version.Version)
fmt.Printf("commit: %s\n", version.GitCommit)
os.Exit(0)
}
@@ -129,7 +125,7 @@ func main() {
case "run":
run(args[1:])
case "version":
version()
printVersion()
case "help":
flag.Usage()
default:

View File

@@ -0,0 +1,9 @@
package version
var (
// Version is the human-readable version
Version = "unknown"
// GitCommit hash, set at compile time
GitCommit = "unknown"
)