Commit 01b3bb31 authored by Darren Shepherd's avatar Darren Shepherd

Fix version printing on startup

parent 56fae079
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"github.com/rancher/k3s/pkg/cli/cmds" "github.com/rancher/k3s/pkg/cli/cmds"
"github.com/rancher/norman/pkg/resolvehome" "github.com/rancher/norman/pkg/resolvehome"
"github.com/rancher/norman/signal" "github.com/rancher/norman/signal"
"github.com/sirupsen/logrus"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
...@@ -25,6 +26,8 @@ func Run(ctx *cli.Context) error { ...@@ -25,6 +26,8 @@ func Run(ctx *cli.Context) error {
return fmt.Errorf("--server is required") return fmt.Errorf("--server is required")
} }
logrus.Infof("Starting k3s agent %s", ctx.App.Version)
dataDir, err := resolvehome.Resolve(cmds.AgentConfig.DataDir) dataDir, err := resolvehome.Resolve(cmds.AgentConfig.DataDir)
if err != nil { if err != nil {
return err return err
...@@ -35,5 +38,6 @@ func Run(ctx *cli.Context) error { ...@@ -35,5 +38,6 @@ func Run(ctx *cli.Context) error {
cfg.DataDir = dataDir cfg.DataDir = dataDir
contextCtx := signal.SigTermCancelContext(context.Background()) contextCtx := signal.SigTermCancelContext(context.Background())
return agent.Run(contextCtx, cfg) return agent.Run(contextCtx, cfg)
} }
...@@ -16,7 +16,7 @@ func NewApp() *cli.App { ...@@ -16,7 +16,7 @@ func NewApp() *cli.App {
app := cli.NewApp() app := cli.NewApp()
app.Name = appName app.Name = appName
app.Usage = "Kubernetes, but small and simple" 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) { cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s version %s\n", app.Name, app.Version) fmt.Printf("%s version %s\n", app.Name, app.Version)
} }
......
...@@ -5,7 +5,7 @@ source $(dirname $0)/version.sh ...@@ -5,7 +5,7 @@ source $(dirname $0)/version.sh
cd $(dirname $0)/.. 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="-extldflags '-static'"
STATIC_SQLITE="-extldflags '-static -lm -ldl -lz -lpthread'" STATIC_SQLITE="-extldflags '-static -lm -ldl -lz -lpthread'"
TAGS="ctrd apparmor seccomp no_btrfs netgo osusergo" TAGS="ctrd apparmor seccomp no_btrfs netgo osusergo"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment