diff --git a/Makefile b/Makefile index a9afd270dc..446916ef2c 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD` GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "dirty-"` VERSION=`git describe --always` GO_VERSION=`go version | awk '{print $$3}'` +BUILD_FLAGS="-X main.gitCommit=${GIT_COMMIT} -X main.version=${VERSION} -X main.goVersion=${GO_VERSION} -X main.buildDate=${BUILD_DATE}" default: build test lint gen-doc check-changelog release: deps build test lint gen-doc @@ -23,17 +24,17 @@ imports: off `go env GOPATH`/bin/goimports -w tools pkg internal cmd build: imports - go build -o ./cmd/revad/revad ./cmd/revad - go build -o ./cmd/reva/reva ./cmd/reva + go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad + go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva tidy: go mod tidy build-revad: imports - go build -o ./cmd/revad/revad ./cmd/revad + go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad build-reva: imports - go build -o ./cmd/reva/reva ./cmd/reva + go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva test: off go test -race ./... @@ -51,8 +52,8 @@ deps: cd /tmp && go get golang.org/x/tools/cmd/goimports build-ci: off - go build -o ./cmd/revad/revad ./cmd/revad - go build -o ./cmd/reva/reva ./cmd/reva + go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad + go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva lint-ci: go run tools/check-license/check-license.go @@ -71,9 +72,9 @@ ci: build-ci test lint-ci # to be run in Docker build build-revad-docker: off - go build -o ./cmd/revad/revad ./cmd/revad + go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad build-reva-docker: off - go build -o ./cmd/reva/reva ./cmd/reva + go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva clean: rm -rf dist diff --git a/changelog/unreleased/build-time-vars.md b/changelog/unreleased/build-time-vars.md new file mode 100644 index 0000000000..6c242a5a2a --- /dev/null +++ b/changelog/unreleased/build-time-vars.md @@ -0,0 +1,7 @@ +Bugfix: Pass build time variables while compiling + +We provide the option of viewing various configuration and version options in +both reva CLI as well as the reva daemon, but we didn't actually have these +values in the first place. This PR adds that info at compile time. + +https://github.com/cs3org/reva/pull/1069 diff --git a/cmd/reva/main.go b/cmd/reva/main.go index 2afdb9b8a3..acc0dacdb8 100644 --- a/cmd/reva/main.go +++ b/cmd/reva/main.go @@ -23,8 +23,6 @@ import ( "fmt" "os" "strings" - - "github.com/cs3org/reva/pkg/sysinfo" ) var ( @@ -43,8 +41,6 @@ func init() { } func main() { - // initiliaze the global system information - sysinfo.InitSystemInfo(&sysinfo.RevaVersion{Version: version, BuildDate: buildDate, GitCommit: gitCommit, GoVersion: goVersion}) cmds := []*command{ versionCommand(), diff --git a/cmd/revad/main.go b/cmd/revad/main.go index d803d5ca00..cfb5cb3a37 100644 --- a/cmd/revad/main.go +++ b/cmd/revad/main.go @@ -52,7 +52,7 @@ var ( func main() { flag.Parse() - // initiliaze the global system information + // initialize the global system information sysinfo.InitSystemInfo(&sysinfo.RevaVersion{Version: version, BuildDate: buildDate, GitCommit: gitCommit, GoVersion: goVersion}) handleVersionFlag() diff --git a/examples/ocmd/ocmd-server-1.toml b/examples/ocmd/ocmd-server-1.toml index 69c239e4fd..07f801fcf5 100644 --- a/examples/ocmd/ocmd-server-1.toml +++ b/examples/ocmd/ocmd-server-1.toml @@ -113,6 +113,9 @@ address = "0.0.0.0:19001" [http.services.dataprovider] driver = "localhome" +[http.services.prometheus] +[http.services.sysinfo] + [http.services.dataprovider.drivers.localhome] user_layout = "{{.Username}}" diff --git a/examples/ocmd/ocmd-server-2.toml b/examples/ocmd/ocmd-server-2.toml index a190f73331..e064fb27a0 100644 --- a/examples/ocmd/ocmd-server-2.toml +++ b/examples/ocmd/ocmd-server-2.toml @@ -96,6 +96,9 @@ address = "0.0.0.0:17001" [http.services.dataprovider] driver = "localhome" +[http.services.prometheus] +[http.services.sysinfo] + [http.services.dataprovider.drivers.localhome] user_layout = "{{.Username}}"