Skip to content

Commit

Permalink
Version now a function
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelycode committed Sep 16, 2015
1 parent ee4ba8b commit e4c96e0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
28 changes: 24 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ var DefaultOrgStore = DefaultSessionManager{}
var DefaultQuotaStore = DefaultSessionManager{}
var MonitoringHandler TykEventHandler
var RPCListener = RPCStorageHandler{}
var VERSION string = "v1.8.3.2"

var ApiSpecRegister = make(map[string]*APISpec)
var keyGen = DefaultKeyGenerator{}
Expand All @@ -49,6 +48,27 @@ const (
OAUTH_PREFIX string = "oauth-data."
)

func VERSION() string {
var maj, min, patch, rel string
maj = strconv.Itoa(MAJOR)
min = strconv.Itoa(MINOR)
patch = strconv.Itoa(PATCH)
rel = strconv.Itoa(RELEASE)

v := strings.Join([]string{
maj,
min,
patch,
rel,
}, ".")

if SUFFIX != "" {
v = strings.Join([]string{v, SUFFIX}, ".")
}

return v
}

// Display configuration options
func displayConfig() {
log.Info("--> Listening on port: ", config.ListenPort)
Expand Down Expand Up @@ -626,7 +646,7 @@ func init() {
--as-version=<version> The version number to use when inserting
`

arguments, err := docopt.Parse(usage, nil, true, VERSION, false, false)
arguments, err := docopt.Parse(usage, nil, true, VERSION(), false, false)
if err != nil {
log.Warning("Error while parsing arguments: ", err)
}
Expand Down Expand Up @@ -821,7 +841,7 @@ func main() {
go s.Serve(l)
displayConfig()
} else {
log.Printf("Gateway started (%v)", VERSION)
log.Printf("Gateway started (%v)", VERSION())
go http.Serve(l, nil)
displayConfig()
}
Expand All @@ -847,7 +867,7 @@ func main() {
go s.Serve(l)
displayConfig()
} else {
log.Printf("Gateway started (%v)", VERSION)
log.Printf("Gateway started (%v)", VERSION())
displayConfig()
http.Serve(l, nil)
}
Expand Down
7 changes: 7 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

var MAJOR int = 1
var MINOR int = 8
var PATCH int = 3
var RELEASE int = 2
var SUFFIX string = ""

0 comments on commit e4c96e0

Please sign in to comment.