Add build-constants.

This commit is contained in:
Harshavardhana
2016-08-17 18:30:01 -07:00
parent 2ea2ec90d2
commit a30f0aca85
7 changed files with 23 additions and 23 deletions
+4 -4
View File
@@ -28,10 +28,10 @@ import (
func genLDFlags(version string) string {
var ldflagsStr string
ldflagsStr = "-X github.com/minio/mc/mc.MCVersion=" + version + " "
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/mc.MCReleaseTag=" + releaseTag(version) + " "
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/mc.MCCommitID=" + commitID() + " "
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/mc.MCShortCommitID=" + commitID()[:12]
ldflagsStr = "-X github.com/minio/mc/cmd.Version=" + version + " "
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/cmd.ReleaseTag=" + releaseTag(version) + " "
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/cmd.CommitID=" + commitID() + " "
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/cmd.ShortCommitID=" + commitID()[:12]
return ldflagsStr
}
+8 -8
View File
@@ -17,12 +17,12 @@
package cmd
var (
// MCVersion - version time.RFC3339.
MCVersion = "DEVELOPMENT.GOGET"
// MCReleaseTag - release tag in TAG.%Y-%m-%dT%H-%M-%SZ.
MCReleaseTag = "DEVELOPMENT.GOGET"
// MCCommitID - latest commit id.
MCCommitID = "DEVELOPMENT.GOGET"
// MCShortCommitID - first 12 characters from MCCommitID.
MCShortCommitID = MCCommitID[:12]
// Version - version time.RFC3339.
Version = "DEVELOPMENT.GOGET"
// ReleaseTag - release tag in TAG.%Y-%m-%dT%H-%M-%SZ.
ReleaseTag = "DEVELOPMENT.GOGET"
// CommitID - latest commit id.
CommitID = "DEVELOPMENT.GOGET"
// ShortCommitID - first 12 characters from CommitID.
ShortCommitID = CommitID[:12]
)
+1 -1
View File
@@ -155,7 +155,7 @@ func newClientFromAlias(alias string, urlStr string) (Client, *probe.Error) {
s3Config.Signature = hostCfg.API
s3Config.AppName = "mc"
s3Config.AppVersion = MCVersion
s3Config.AppVersion = Version
s3Config.AppComments = []string{os.Args[0], runtime.GOOS, runtime.GOARCH}
s3Config.HostURL = urlStr
s3Config.Debug = globalDebug
+3 -3
View File
@@ -56,7 +56,7 @@ GLOBAL FLAGS:
{{range .Flags}}{{.}}
{{end}}{{end}}
VERSION:
` + MCVersion +
` + Version +
`{{ "\n"}}{{range $key, $value := ExtraInfo}}
{{$key}}:
{{$value}}
@@ -76,8 +76,8 @@ func Main() {
}
probe.Init() // Set project's root source path.
probe.SetAppInfo("Release-Tag", MCReleaseTag)
probe.SetAppInfo("Commit", MCShortCommitID)
probe.SetAppInfo("Release-Tag", ReleaseTag)
probe.SetAppInfo("Commit", ShortCommitID)
app := registerApp()
app.Before = registerBefore
+3 -3
View File
@@ -164,12 +164,12 @@ func getReleaseUpdate(updateURL string) {
data, e := client.Get(newUpdateURL)
fatalIf(probe.NewError(e), "Unable to read from update URL ‘"+newUpdateURL+"’.")
if strings.HasPrefix(MCVersion, "DEVELOPMENT.GOGET") {
if strings.HasPrefix(Version, "DEVELOPMENT.GOGET") {
fatalIf(errDummy().Trace(newUpdateURL),
"Update mechanism is not supported for ‘go get’ based binary builds. Please download official releases from https://minio.io/#minio")
}
current, e := time.Parse(time.RFC3339, MCVersion)
current, e := time.Parse(time.RFC3339, Version)
fatalIf(probe.NewError(e), "Unable to parse version string as time.")
if current.IsZero() {
@@ -190,7 +190,7 @@ func getReleaseUpdate(updateURL string) {
updateMsg := updateMessage{
Download: downloadURL,
Version: MCVersion,
Version: Version,
}
if latest.After(current) {
updateMsg.Update = true
+3 -3
View File
@@ -89,9 +89,9 @@ func mainVersion(ctx *cli.Context) {
console.SetColor("CommitID", color.New(color.FgGreen))
verMsg := versionMessage{}
verMsg.CommitID = MCCommitID
verMsg.ReleaseTag = MCReleaseTag
verMsg.Version.Value = MCVersion
verMsg.CommitID = CommitID
verMsg.ReleaseTag = ReleaseTag
verMsg.Version.Value = Version
verMsg.Version.Format = "RFC3339"
printMsg(verMsg)
+1 -1
View File
@@ -24,6 +24,6 @@ import (
)
func (s *TestSuite) TestVersion(c *C) {
_, e := time.Parse(MCVersion, http.TimeFormat)
_, e := time.Parse(Version, http.TimeFormat)
c.Assert(e, NotNil)
}