Skip to content

Commit

Permalink
Versioning: Get the version from the right place
Browse files Browse the repository at this point in the history
The "hyper" calico changes meant that startup.go would never get a
version populated.

Instead, let's just get versioning information from one place. It can't
be "main" since startup can't import that, so at build time just store
the version in startup.VERSION then the version command in main.go can
retrieve it from there.
  • Loading branch information
tomdee committed Aug 10, 2018
1 parent dc025ea commit 76ec8a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ MAKE_SURE_BIN_EXIST := $(shell mkdir -p dist .go-pkg-cache $(NODE_CONTAINER_BIN_
NODE_CONTAINER_FILES=$(shell find ./filesystem -type f)
SRCFILES=$(shell find ./pkg -name '*.go')
LOCAL_USER_ID?=$(shell id -u $$USER)
LDFLAGS=-ldflags "-X main.VERSION=$(CALICO_GIT_VER)"
LDFLAGS=-ldflags "-X github.com/projectcalico/node/pkg/startup.VERSION=$(CALICO_GIT_VER)"
PACKAGE_NAME?=github.com/projectcalico/node
LIBCALICOGO_PATH?=none

Expand Down
5 changes: 1 addition & 4 deletions cmd/calico-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import (
"github.com/sirupsen/logrus"
)

// Populated by build - used for printing version.
var VERSION string

// Create a new flag set.
var flagSet = flag.NewFlagSet("Calico", flag.ContinueOnError)

Expand Down Expand Up @@ -89,7 +86,7 @@ func main() {

// Decide which action to take based on the given flags.
if *version {
fmt.Println(VERSION)
fmt.Println(startup.VERSION)
os.Exit(0)
} else if *runFelix {
felix.Run("/etc/calico/felix.cfg")
Expand Down

0 comments on commit 76ec8a5

Please sign in to comment.