From f5ff7e15cf7c0d095dcbbd1bdbab5767b9ea7bd6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 13 Aug 2016 13:49:18 -0700 Subject: [PATCH] mc: Fix release build flags after recent refactor. (#1794) --- Makefile | 14 ++++---------- buildscripts/gen-ldflags.go | 10 +++++----- command/build-constants.go | 16 ++++++++-------- command/common-methods.go | 3 +-- command/globals.go | 2 +- command/main.go | 6 +++--- command/session-v7.go | 4 ++-- command/trie.go | 4 ++-- command/update-main.go | 6 +++--- command/version-main.go | 6 +++--- command/version_test.go | 2 +- main.go | 4 +--- 12 files changed, 34 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index f70cd4be..96f4b4c4 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,8 @@ vet: @GO15VENDOREXPERIMENT=1 go tool vet -shadow=true ./pkg spelling: - @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/misspell *.go - @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/misspell command/**/* + @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/misspell * + @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/misspell command/* @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/misspell pkg/**/* fmt: @@ -38,12 +38,11 @@ fmt: lint: @echo "Running $@:" @GO15VENDOREXPERIMENT=1 $(GOPATH)/bin/golint . - @GO15VENDOREXPERIMENT=1 $(GOPATH)/bin/golint github.com/minio/mc/command + @GO15VENDOREXPERIMENT=1 $(GOPATH)/bin/golint github.com/minio/mc/command... @GO15VENDOREXPERIMENT=1 $(GOPATH)/bin/golint github.com/minio/mc/pkg... cyclo: @echo "Running $@:" - @GO15VENDOREXPERIMENT=1 $(GOPATH)/bin/gocyclo -over 40 *.go @GO15VENDOREXPERIMENT=1 $(GOPATH)/bin/gocyclo -over 40 command @GO15VENDOREXPERIMENT=1 $(GOPATH)/bin/gocyclo -over 40 pkg @@ -56,18 +55,13 @@ build: getdeps verifiers test: getdeps verifiers @echo "Running all testing:" - @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) ./ - @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/mc/command + @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/mc/command... @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/mc/pkg... gomake-all: build @GO15VENDOREXPERIMENT=1 go build --ldflags "$(LDFLAGS)" -o $(GOPATH)/bin/mc @mkdir -p $(HOME)/.mc -coverage: - @GO15VENDOREXPERIMENT=1 go test -race -coverprofile=cover.out ./ - @go tool cover -html=cover.out && echo "Visit your browser" - pkg-validate-arg-%: ; ifndef PKG diff --git a/buildscripts/gen-ldflags.go b/buildscripts/gen-ldflags.go index f3a659f9..be553661 100644 --- a/buildscripts/gen-ldflags.go +++ b/buildscripts/gen-ldflags.go @@ -1,7 +1,7 @@ // +build ignore /* - * Mc Client (C) 2014, 2015 Mc, Inc. + * Mc Client (C) 2014, 2015, 2016 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,10 +28,10 @@ import ( func genLDFlags(version string) string { var ldflagsStr string - ldflagsStr = "-X main.mcVersion=" + version + " " - ldflagsStr = ldflagsStr + "-X main.mcReleaseTag=" + releaseTag(version) + " " - ldflagsStr = ldflagsStr + "-X main.mcCommitID=" + commitID() + " " - ldflagsStr = ldflagsStr + "-X main.mcShortCommitID=" + commitID()[:12] + ldflagsStr = "-X github.com/minio/mc/command.MCVersion=" + version + " " + ldflagsStr = ldflagsStr + "-X github.com/minio/mc/command.MCReleaseTag=" + releaseTag(version) + " " + ldflagsStr = ldflagsStr + "-X github.com/minio/mc/command.MCCommitID=" + commitID() + " " + ldflagsStr = ldflagsStr + "-X github.com/minio/mc/command.MCShortCommitID=" + commitID()[:12] return ldflagsStr } diff --git a/command/build-constants.go b/command/build-constants.go index 3ca2c452..022c5c9d 100644 --- a/command/build-constants.go +++ b/command/build-constants.go @@ -17,12 +17,12 @@ package command 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] + // 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] ) diff --git a/command/common-methods.go b/command/common-methods.go index 7f0d06bf..0bb00708 100644 --- a/command/common-methods.go +++ b/command/common-methods.go @@ -155,11 +155,10 @@ func newClientFromAlias(alias string, urlStr string) (Client, *probe.Error) { s3Config.Signature = hostCfg.API s3Config.AppName = "mc" - s3Config.AppVersion = mcVersion + s3Config.AppVersion = MCVersion s3Config.AppComments = []string{os.Args[0], runtime.GOOS, runtime.GOARCH} s3Config.HostURL = urlStr s3Config.Debug = globalDebug - s3Client, err := s3New(s3Config) if err != nil { return nil, err.Trace(alias, urlStr) diff --git a/command/globals.go b/command/globals.go index de151ada..0cdf23af 100644 --- a/command/globals.go +++ b/command/globals.go @@ -14,7 +14,7 @@ * limitations under the License. */ -// This package contains all the global variables and constants. ONLY TO BE ACCESSED VIA GET/SET FUNCTIONS. +// Package command contains all the global variables and constants. ONLY TO BE ACCESSED VIA GET/SET FUNCTIONS. package command import ( diff --git a/command/main.go b/command/main.go index 9851c1cd..4cf4ba97 100644 --- a/command/main.go +++ b/command/main.go @@ -56,7 +56,7 @@ GLOBAL FLAGS: {{range .Flags}}{{.}} {{end}}{{end}} VERSION: - ` + mcVersion + + ` + MCVersion + `{{ "\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", MCReleaseTag) + probe.SetAppInfo("Commit", MCShortCommitID) app := registerApp() app.Before = registerBefore diff --git a/command/session-v7.go b/command/session-v7.go index 0b83abe2..2d9f5555 100644 --- a/command/session-v7.go +++ b/command/session-v7.go @@ -1,5 +1,5 @@ /* - * Minio Client, (C) 2015 Minio, Inc. + * Minio Client, (C) 2015, 2016 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -// Session V2 - Version 2 stores session header and session data in +// Package command - session V7 - Version 7 stores session header and session data in // two separate files. Session data contains fully prepared URL list. package command diff --git a/command/trie.go b/command/trie.go index f8a4b8f9..484b9e63 100644 --- a/command/trie.go +++ b/command/trie.go @@ -1,5 +1,5 @@ /* - * Minio Client (C) 2014, 2015 Minio, Inc. + * Minio Client (C) 2014, 2015, 2016 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -// This file implements a simple trie tree to be used for 'mc' cli commands. +// Package command - This file implements a simple trie tree to be used for 'mc' cli commands. package command // This package borrows idea from - https://godoc.org/golang.org/x/text/internal/triegen. diff --git a/command/update-main.go b/command/update-main.go index 086fb5c5..5231b76c 100644 --- a/command/update-main.go +++ b/command/update-main.go @@ -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(MCVersion, "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, MCVersion) 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: MCVersion, } if latest.After(current) { updateMsg.Update = true diff --git a/command/version-main.go b/command/version-main.go index cffa0909..2061a5d5 100644 --- a/command/version-main.go +++ b/command/version-main.go @@ -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 = MCCommitID + verMsg.ReleaseTag = MCReleaseTag + verMsg.Version.Value = MCVersion verMsg.Version.Format = "RFC3339" printMsg(verMsg) diff --git a/command/version_test.go b/command/version_test.go index 14e5eed0..bff321f8 100644 --- a/command/version_test.go +++ b/command/version_test.go @@ -24,6 +24,6 @@ import ( ) func (s *TestSuite) TestVersion(c *C) { - _, e := time.Parse(mcVersion, http.TimeFormat) + _, e := time.Parse(MCVersion, http.TimeFormat) c.Assert(e, NotNil) } diff --git a/main.go b/main.go index 96ce11d5..461bc65f 100644 --- a/main.go +++ b/main.go @@ -16,9 +16,7 @@ package main -import ( - command "github.com/minio/mc/command" -) +import command "github.com/minio/mc/command" func main() { command.Main()