Skip to content

Commit

Permalink
Fix version printing on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Feb 8, 2019
1 parent 56fae07 commit 01b3bb3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/cli/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
Expand All @@ -35,5 +38,6 @@ func Run(ctx *cli.Context) error {
cfg.DataDir = dataDir

contextCtx := signal.SigTermCancelContext(context.Background())

return agent.Run(contextCtx, cfg)
}
2 changes: 1 addition & 1 deletion pkg/cli/cmds/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 01b3bb3

Please sign in to comment.