diff --git a/Makefile b/Makefile index 89c33ec..2002d19 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ DEFAULT_VERSION=0.1.0-local VERSION := $(or $(VERSION),$(DEFAULT_VERSION)) cmd: - cd server && go build -ldflags "-w -X main.Version=$(VERSION)" -o '../build/server' + cd server && go build -ldflags "-w -X main.VERSION=$(VERSION)" -o '../build/server' clean: rm -rf build test: diff --git a/server/env/env.go b/server/env/env.go index 32283da..7a28921 100644 --- a/server/env/env.go +++ b/server/env/env.go @@ -12,7 +12,6 @@ import ( // build variables var ( - VERSION string ARG_DB_URL *string ARG_DB_TYPE *string ARG_AUTHORIZER_URL *string @@ -34,8 +33,6 @@ func InitEnv() { log.Printf("error loading %s file", constants.ENV_PATH) } - constants.VERSION = VERSION - if constants.ADMIN_SECRET == "" { constants.ADMIN_SECRET = os.Getenv("ADMIN_SECRET") if constants.ADMIN_SECRET == "" { diff --git a/server/main.go b/server/main.go index 594553f..8a3aeef 100644 --- a/server/main.go +++ b/server/main.go @@ -13,6 +13,8 @@ import ( "github.com/authorizerdev/authorizer/server/utils" ) +var VERSION string + func main() { env.ARG_DB_URL = flag.String("database_url", "", "Database connection string") env.ARG_DB_TYPE = flag.String("database_type", "", "Database type, possible values are postgres,mysql,sqlite") @@ -20,6 +22,8 @@ func main() { env.ARG_ENV_FILE = flag.String("env_file", "", "Env file path") flag.Parse() + constants.VERSION = VERSION + env.InitEnv() db.InitDB() session.InitSession()