Merge pull request #840 from harshavardhana/version

Version is a package now, will be re-used across codebase.
master
Harshavardhana 9 years ago
commit c223427cbf
  1. 2
      Makefile
  2. 3
      main.go
  3. 4
      pkg/server/api/headers.go
  4. 2
      pkg/version/genversion.go
  5. 2
      pkg/version/version.go
  6. 37
      pkg/version/version_test.go
  7. 12
      verify-runtime.go
  8. 3
      version-main.go

@ -50,7 +50,7 @@ release: genversion
genversion:
@echo "Generating new minio version.go"
@go run genversion.go
@cd ./pkg/version; go run genversion.go; cd - 1>/dev/null
pkg-remove:
@GO15VENDOREXPERIMENT=1 govendor remove $(PKG)

@ -27,6 +27,7 @@ import (
"github.com/dustin/go-humanize"
"github.com/minio/cli"
"github.com/minio/minio/pkg/version"
)
func init() {
@ -80,7 +81,7 @@ func init() {
// getFormattedVersion -
func getFormattedVersion() string {
t, _ := time.Parse(time.RFC3339Nano, Version)
t, _ := time.Parse(time.RFC3339Nano, version.Version)
if t.IsZero() {
return ""
}

@ -22,9 +22,11 @@ import (
"encoding/json"
"encoding/xml"
"net/http"
"runtime"
"strconv"
"github.com/minio/minio/pkg/donut"
"github.com/minio/minio/pkg/version"
)
// No encoder interface exists, so we create one.
@ -51,7 +53,7 @@ func generateRequestID() []byte {
func setCommonHeaders(w http.ResponseWriter, acceptsType string, contentLength int) {
// set unique request ID for each reply
w.Header().Set("X-Amz-Request-Id", string(generateRequestID()))
w.Header().Set("Server", "Minio")
w.Header().Set("Server", ("Minio/" + version.Version + " (" + runtime.GOOS + "," + runtime.GOARCH + ")"))
w.Header().Set("Accept-Ranges", "bytes")
w.Header().Set("Content-Type", acceptsType)
w.Header().Set("Connection", "close")

@ -35,7 +35,7 @@ func writeVersion(version Version) error {
var versionTemplate = `// -------- DO NOT EDIT --------
// This file is autogenerated by genversion.go during the release process.
package main
package version
// Version autogenerated
const Version = {{if .Date}}"{{.Date}}"{{else}}""{{end}}

@ -1,7 +1,7 @@
// -------- DO NOT EDIT --------
// This file is autogenerated by genversion.go during the release process.
package main
package version
// Version autogenerated
const Version = "2015-08-14T03:23:47.250240049Z"

@ -0,0 +1,37 @@
/*
* Minio Cloud Storage, (C) 2015 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package version_test
import (
"testing"
"time"
"github.com/minio/minio/pkg/version"
. "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
type MySuite struct{}
var _ = Suite(&MySuite{})
func (s *MySuite) TestVersion(c *C) {
_, err := time.Parse(version.Version, time.RFC3339Nano)
c.Assert(err, NotNil)
}

@ -44,12 +44,12 @@ func getNormalizedGolangVersion() string {
return version
}
type version struct {
type golangVersion struct {
major, minor, patch string
}
func newVersion(v string) version {
ver := version{}
func newVersion(v string) golangVersion {
ver := golangVersion{}
verSlice := strings.Split(v, ".")
if len(verSlice) < 2 {
Fatalln("Version string missing major and minor versions, cannot proceed exiting.")
@ -67,11 +67,11 @@ func newVersion(v string) version {
return ver
}
func (v1 version) String() string {
func (v1 golangVersion) String() string {
return fmt.Sprintf("%s%s%s", v1.major, v1.minor, v1.patch)
}
func (v1 version) Version() int {
func (v1 golangVersion) Version() int {
ver, e := strconv.Atoi(v1.String())
if e != nil {
Fatalln("Unable to parse version string.")
@ -79,7 +79,7 @@ func (v1 version) Version() int {
return ver
}
func (v1 version) LessThan(v2 version) bool {
func (v1 golangVersion) LessThan(v2 golangVersion) bool {
if v1.Version() < v2.Version() {
return true
}

@ -21,6 +21,7 @@ import (
"time"
"github.com/minio/cli"
"github.com/minio/minio/pkg/version"
)
var versionCmd = cli.Command{
@ -39,7 +40,7 @@ EXAMPLES:
}
func mainVersion(ctxx *cli.Context) {
t, _ := time.Parse(time.RFC3339Nano, Version)
t, _ := time.Parse(time.RFC3339Nano, version.Version)
if t.IsZero() {
Println("")
return

Loading…
Cancel
Save