Fix version printing on startup

This commit is contained in:
Darren Shepherd 2019-02-07 21:28:09 -07:00
parent 56fae079e5
commit 01b3bb315e
3 changed files with 6 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/rancher/k3s/pkg/cli/cmds"
"github.com/rancher/norman/pkg/resolvehome"
"github.com/rancher/norman/signal"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@ -25,6 +26,8 @@ func Run(ctx *cli.Context) error {
return fmt.Errorf("--server is required")
}
logrus.Infof("Starting k3s agent %s", ctx.App.Version)
dataDir, err := resolvehome.Resolve(cmds.AgentConfig.DataDir)
if err != nil {
return err
@ -35,5 +38,6 @@ func Run(ctx *cli.Context) error {
cfg.DataDir = dataDir
contextCtx := signal.SigTermCancelContext(context.Background())
return agent.Run(contextCtx, cfg)
}

View File

@ -16,7 +16,7 @@ func NewApp() *cli.App {
app := cli.NewApp()
app.Name = appName
app.Usage = "Kubernetes, but small and simple"
app.Version = version.Version
app.Version = fmt.Sprintf("%s (%s)", version.Version, version.GitCommit)
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s version %s\n", app.Name, app.Version)
}

View File

@ -5,7 +5,7 @@ source $(dirname $0)/version.sh
cd $(dirname $0)/..
LDFLAGS="-X github.com/rancher/k3s/version.Version=$VERSION -w -s"
LDFLAGS="-X github.com/rancher/k3s/pkg/version.Version=$VERSION -X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8} -w -s"
STATIC="-extldflags '-static'"
STATIC_SQLITE="-extldflags '-static -lm -ldl -lz -lpthread'"
TAGS="ctrd apparmor seccomp no_btrfs netgo osusergo"