2015-11-09 18:52:55 +00:00
|
|
|
package version
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// The git commit that was compiled. This will be filled in by the compiler.
|
|
|
|
var GitCommit string
|
|
|
|
var GitDescribe string
|
|
|
|
|
|
|
|
// The main version number that is being run at the moment.
|
2016-05-23 19:37:34 +00:00
|
|
|
const Version = "0.6.0"
|
2015-11-09 18:52:55 +00:00
|
|
|
|
|
|
|
// A pre-release marker for the version. If this is "" (empty string)
|
|
|
|
// then it means that it is a final release. Otherwise, this is a pre-release
|
|
|
|
// such as "dev" (in development), "beta", "rc1", etc.
|
2016-05-25 21:54:44 +00:00
|
|
|
const VersionPrerelease = "beta2"
|
2015-11-09 18:52:55 +00:00
|
|
|
|
|
|
|
// VersionInfo
|
|
|
|
type VersionInfo struct {
|
|
|
|
Revision string
|
|
|
|
Version string
|
|
|
|
VersionPrerelease string
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetVersion() *VersionInfo {
|
|
|
|
ver := Version
|
|
|
|
rel := VersionPrerelease
|
|
|
|
if GitDescribe != "" {
|
|
|
|
ver = GitDescribe
|
|
|
|
}
|
|
|
|
if GitDescribe == "" && rel == "" && VersionPrerelease != "" {
|
|
|
|
rel = "dev"
|
|
|
|
}
|
|
|
|
|
|
|
|
return &VersionInfo{
|
|
|
|
Revision: GitCommit,
|
|
|
|
Version: ver,
|
|
|
|
VersionPrerelease: rel,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *VersionInfo) String() string {
|
|
|
|
var versionString bytes.Buffer
|
|
|
|
|
|
|
|
fmt.Fprintf(&versionString, "Vault v%s", c.Version)
|
|
|
|
if c.VersionPrerelease != "" {
|
|
|
|
fmt.Fprintf(&versionString, "-%s", c.VersionPrerelease)
|
|
|
|
|
|
|
|
if c.Revision != "" {
|
|
|
|
fmt.Fprintf(&versionString, " (%s)", c.Revision)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return versionString.String()
|
|
|
|
}
|