Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass build time variables while compiling #1069

Merged
merged 2 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ./...
Expand All @@ -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
Expand All @@ -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

Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/build-time-vars.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions cmd/reva/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"fmt"
"os"
"strings"

"github.com/cs3org/reva/pkg/sysinfo"
)

var (
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion cmd/revad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions examples/ocmd/ocmd-server-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"

Expand Down
3 changes: 3 additions & 0 deletions examples/ocmd/ocmd-server-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"

Expand Down