build: Handle builds on env where CGO_ENABLED=0

Fixes #1033
master
Harshavardhana 9 years ago
parent 3cb92bdf9c
commit 88686dc6e3
  1. 18
      .travis.yml
  2. 20
      vendor.json
  3. 3
      vendor/github.com/minio/minio-xl/pkg/crypto/sha256/sha256_darwin.go
  4. 2
      vendor/github.com/minio/minio-xl/pkg/crypto/sha256/sha256_linux.go
  5. 2
      vendor/github.com/minio/minio-xl/pkg/crypto/sha256/sha256_linux_amd64.go
  6. 2
      vendor/github.com/minio/minio-xl/pkg/crypto/sha256/sha256_linux_amd64_test.go
  7. 53
      vendor/github.com/minio/minio-xl/pkg/crypto/sha256/sha256_linux_arm.go
  8. 3
      vendor/github.com/minio/minio-xl/pkg/crypto/sha256/sha256_windows.go
  9. 53
      vendor/github.com/minio/minio-xl/pkg/crypto/sha256/sha256_windows_amd64.go
  10. 2
      vendor/github.com/minio/minio-xl/pkg/crypto/sha256/sha256block_linux_amd64.go
  11. 3
      vendor/github.com/minio/minio-xl/pkg/crypto/sha512/sha512_darwin.go
  12. 58
      vendor/github.com/minio/minio-xl/pkg/crypto/sha512/sha512_darwin_amd64.go
  13. 2
      vendor/github.com/minio/minio-xl/pkg/crypto/sha512/sha512_linux.go
  14. 2
      vendor/github.com/minio/minio-xl/pkg/crypto/sha512/sha512_linux_amd64.go
  15. 2
      vendor/github.com/minio/minio-xl/pkg/crypto/sha512/sha512_linux_amd64_test.go
  16. 3
      vendor/github.com/minio/minio-xl/pkg/crypto/sha512/sha512_windows.go
  17. 58
      vendor/github.com/minio/minio-xl/pkg/crypto/sha512/sha512_windows_amd64.go
  18. 2
      vendor/github.com/minio/minio-xl/pkg/crypto/sha512/sha512block_linux_amd64.go
  19. 149
      vendor/github.com/minio/minio-xl/pkg/quick/quick.go
  20. 59
      vendor/github.com/minio/minio-xl/pkg/quick/quick_test.go
  21. 16
      vendor/vendor.json

@ -1,10 +1,24 @@
sudo: false
language: go
os:
- linux
- osx
osx_image: xcode7.2
env:
- ARCH=x86_64
- ARCH=i686
script:
- make test
- make test GOFLAGS="-race"
sudo: false
go:
- 1.5.1
- 1.5.2
- 1.5.3
notifications:
slack:
secure: K9tsn5MvrCAxuEZTxn+m3Kq1K2NG2xMEJFSv/sTp+RQBW7TslPHzv859GsIvrm8mU1y1btOU9RlOzqrRUczI5cJpE8IL1oljPZbXrIXgetE0kbsw0Wpy99g27UQ2VGp933WDu8tfj7zU4cZv+BI0RltNLwqYO6GWXmcWP0IueCU=

@ -1,20 +0,0 @@
{
"comment": "",
"ignore": "",
"package": [
{
"canonical": "github.com/minio/minio-xl/pkg/atomic",
"comment": "",
"local": "vendor/github.com/minio/minio-xl/pkg/atomic",
"revision": "a32fbc1006b4a09176c91f57d22e87faff22a423",
"revisionTime": "2015-11-17T22:59:41-08:00"
},
{
"canonical": "github.com/minio/minio-xl/pkg/quick",
"comment": "",
"local": "vendor/github.com/minio/minio-xl/pkg/quick",
"revision": "a32fbc1006b4a09176c91f57d22e87faff22a423",
"revisionTime": "2015-11-17T22:59:41-08:00"
}
]
}

@ -1,3 +1,6 @@
// +build 386 amd64 arm
// +build darwin
/*
* Minio Cloud Storage, (C) 2014 Minio, Inc.
*

@ -1,3 +1,5 @@
// +build 386 arm amd64,!cgo
/*
* Minio Cloud Storage, (C) 2015 Minio, Inc.
*

@ -1,3 +1,5 @@
// +build amd64,cgo
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file of

@ -1,3 +1,5 @@
// +build amd64,cgo
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file of

@ -1,53 +0,0 @@
/*
* 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 sha256
import (
"hash"
"io"
"crypto/sha256"
)
// Sum256 - single caller sha256 helper
func Sum256(data []byte) []byte {
d := sha256.New()
d.Write(data)
return d.Sum(nil)
}
// Sum - io.Reader based streaming sha256 helper
func Sum(reader io.Reader) ([]byte, error) {
d := sha256.New()
var err error
for err == nil {
length := 0
byteBuffer := make([]byte, 1024*1024)
length, err = reader.Read(byteBuffer)
byteBuffer = byteBuffer[0:length]
d.Write(byteBuffer)
}
if err != io.EOF {
return nil, err
}
return d.Sum(nil), nil
}
// New returns a new hash.Hash computing SHA256.
func New() hash.Hash {
return sha256.New()
}

@ -1,3 +1,6 @@
// +build 386 amd64 arm
// +build windows
/*
* Minio Cloud Storage, (C) 2014 Minio, Inc.
*

@ -1,53 +0,0 @@
/*
* Minio Cloud Storage, (C) 2014 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 sha256
import (
"hash"
"io"
"crypto/sha256"
)
// Sum256 - single caller sha256 helper
func Sum256(data []byte) []byte {
d := sha256.New()
d.Write(data)
return d.Sum(nil)
}
// Sum - io.Reader based streaming sha256 helper
func Sum(reader io.Reader) ([]byte, error) {
d := sha256.New()
var err error
for err == nil {
length := 0
byteBuffer := make([]byte, 1024*1024)
length, err = reader.Read(byteBuffer)
byteBuffer = byteBuffer[0:length]
d.Write(byteBuffer)
}
if err != io.EOF {
return nil, err
}
return d.Sum(nil), nil
}
// New returns a new hash.Hash computing SHA256.
func New() hash.Hash {
return sha256.New()
}

@ -1,4 +1,4 @@
// +build amd64
// +build amd64,cgo
//
// Minio Cloud Storage, (C) 2015 Minio, Inc.

@ -1,3 +1,6 @@
// +build 386 amd64 arm
// +build darwin
/*
* Minio Cloud Storage, (C) 2014 Minio, Inc.
*

@ -1,58 +0,0 @@
/*
* Minio Cloud Storage, (C) 2014 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 sha512
import (
"hash"
"io"
"crypto/sha512"
)
// The size of a SHA512 checksum in bytes.
const (
Size = sha512.Size
)
// Sum512 - single caller sha512 helper
func Sum512(data []byte) []byte {
d := sha512.New()
d.Write(data)
return d.Sum(nil)
}
// Sum - io.Reader based streaming sha512 helper
func Sum(reader io.Reader) ([]byte, error) {
d := sha512.New()
var err error
for err == nil {
length := 0
byteBuffer := make([]byte, 1024*1024)
length, err = reader.Read(byteBuffer)
byteBuffer = byteBuffer[0:length]
d.Write(byteBuffer)
}
if err != io.EOF {
return nil, err
}
return d.Sum(nil), nil
}
// New returns a new hash.Hash computing SHA512.
func New() hash.Hash {
return sha512.New()
}

@ -1,3 +1,5 @@
// +build 386 arm amd64,!cgo
/*
* Minio Cloud Storage, (C) 2014 Minio, Inc.
*

@ -1,3 +1,5 @@
// +build amd64,cgo
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file of

@ -1,3 +1,5 @@
// +build amd64,cgo
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file of

@ -1,3 +1,6 @@
// +build 386 amd64 arm
// +build windows
/*
* Minio Cloud Storage, (C) 2014 Minio, Inc.
*

@ -1,58 +0,0 @@
/*
* Minio Cloud Storage, (C) 2014 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 sha512
import (
"hash"
"io"
"crypto/sha512"
)
// The size of a SHA512 checksum in bytes.
const (
Size = sha512.Size
)
// Sum512 - single caller sha512 helper
func Sum512(data []byte) []byte {
d := sha512.New()
d.Write(data)
return d.Sum(nil)
}
// Sum - io.Reader based streaming sha512 helper
func Sum(reader io.Reader) ([]byte, error) {
d := sha512.New()
var err error
for err == nil {
length := 0
byteBuffer := make([]byte, 1024*1024)
length, err = reader.Read(byteBuffer)
byteBuffer = byteBuffer[0:length]
d.Write(byteBuffer)
}
if err != io.EOF {
return nil, err
}
return d.Sum(nil), nil
}
// New returns a new hash.Hash computing SHA512.
func New() hash.Hash {
return sha512.New()
}

@ -1,4 +1,4 @@
// +build amd64
// +build amd64,cgo
//
// Minio Cloud Storage, (C) 2015 Minio, Inc.

@ -72,8 +72,7 @@ func CheckData(data interface{}) *probe.Error {
// New - instantiate a new config
func New(data interface{}) (Config, *probe.Error) {
err := CheckData(data)
if err != nil {
if err := CheckData(data); err != nil {
return nil, err.Trace()
}
@ -86,14 +85,14 @@ func New(data interface{}) (Config, *probe.Error) {
// CheckVersion - loads json and compares the version number provided returns back true or false - any failure
// is returned as error.
func CheckVersion(filename string, version string) (bool, *probe.Error) {
_, err := os.Stat(filename)
if err != nil {
return false, probe.NewError(err)
_, e := os.Stat(filename)
if e != nil {
return false, probe.NewError(e)
}
fileData, err := ioutil.ReadFile(filename)
if err != nil {
return false, probe.NewError(err)
fileData, e := ioutil.ReadFile(filename)
if e != nil {
return false, probe.NewError(e)
}
if runtime.GOOS == "windows" {
@ -104,18 +103,18 @@ func CheckVersion(filename string, version string) (bool, *probe.Error) {
}{
Version: "",
}
err = json.Unmarshal(fileData, &data)
if err != nil {
switch err := err.(type) {
e = json.Unmarshal(fileData, &data)
if e != nil {
switch e := e.(type) {
case *json.SyntaxError:
return false, probe.NewError(FormatJSONSyntaxError(bytes.NewReader(fileData), err))
return false, probe.NewError(FormatJSONSyntaxError(bytes.NewReader(fileData), e))
default:
return false, probe.NewError(err)
return false, probe.NewError(e)
}
}
config, perr := New(data)
if perr != nil {
return false, perr.Trace()
config, err := New(data)
if err != nil {
return false, err.Trace()
}
if config.Version() != version {
return false, nil
@ -125,33 +124,33 @@ func CheckVersion(filename string, version string) (bool, *probe.Error) {
// Load - loads json config from filename for the a given struct data
func Load(filename string, data interface{}) (Config, *probe.Error) {
_, err := os.Stat(filename)
if err != nil {
return nil, probe.NewError(err)
_, e := os.Stat(filename)
if e != nil {
return nil, probe.NewError(e)
}
fileData, err := ioutil.ReadFile(filename)
if err != nil {
return nil, probe.NewError(err)
fileData, e := ioutil.ReadFile(filename)
if e != nil {
return nil, probe.NewError(e)
}
if runtime.GOOS == "windows" {
fileData = []byte(strings.Replace(string(fileData), "\r\n", "\n", -1))
}
err = json.Unmarshal(fileData, &data)
if err != nil {
switch err := err.(type) {
e = json.Unmarshal(fileData, &data)
if e != nil {
switch e := e.(type) {
case *json.SyntaxError:
return nil, probe.NewError(FormatJSONSyntaxError(bytes.NewReader(fileData), err))
return nil, probe.NewError(FormatJSONSyntaxError(bytes.NewReader(fileData), e))
default:
return nil, probe.NewError(err)
return nil, probe.NewError(e)
}
}
config, perr := New(data)
if perr != nil {
return nil, perr.Trace()
config, err := New(data)
if err != nil {
return nil, err.Trace()
}
return config, nil
@ -174,6 +173,25 @@ func (d config) Version() string {
return ""
}
// writeFile writes data to a file named by filename.
// If the file does not exist, writeFile creates it;
// otherwise writeFile truncates it before writing.
func writeFile(filename string, data []byte) *probe.Error {
atomicFile, e := atomic.FileCreate(filename)
if e != nil {
return probe.NewError(e)
}
_, e = atomicFile.Write(data)
if e != nil {
return probe.NewError(e)
}
e = atomicFile.Close()
if e != nil {
return probe.NewError(e)
}
return nil
}
// String converts JSON config to printable string
func (d config) String() string {
configBytes, _ := json.MarshalIndent(d.data, "", "\t")
@ -185,29 +203,42 @@ func (d config) Save(filename string) *probe.Error {
d.lock.Lock()
defer d.lock.Unlock()
jsonData, err := json.MarshalIndent(d.data, "", "\t")
if err != nil {
return probe.NewError(err)
// Check for existing file, if yes create a backup.
st, e := os.Stat(filename)
// If file exists and stat failed return here.
if e != nil && !os.IsNotExist(e) {
return probe.NewError(e)
}
// File exists and proceed to take backup.
if e == nil {
// File exists and is not a regular file return error.
if !st.Mode().IsRegular() {
return probe.NewError(fmt.Errorf("%s is not a regular file", filename))
}
// Read old data.
var oldData []byte
oldData, e = ioutil.ReadFile(filename)
if e != nil {
return probe.NewError(e)
}
// Save read data to the backup file.
if err := writeFile(filename+".old", oldData); err != nil {
return err.Trace(filename + ".old")
}
}
// Proceed to create or overwrite file.
jsonData, e := json.MarshalIndent(d.data, "", "\t")
if e != nil {
return probe.NewError(e)
}
if runtime.GOOS == "windows" {
jsonData = []byte(strings.Replace(string(jsonData), "\n", "\r\n", -1))
}
atomicFile, err := atomic.FileCreate(filename)
if err != nil {
return probe.NewError(err)
}
_, err = atomicFile.Write(jsonData)
if err != nil {
return probe.NewError(err)
}
err = atomicFile.Close()
if err != nil {
return probe.NewError(err)
}
return nil
// Save data.
err := writeFile(filename, jsonData)
return err.Trace(filename)
}
// Load - loads JSON config from file and merge with currently set values
@ -215,14 +246,14 @@ func (d *config) Load(filename string) *probe.Error {
d.lock.Lock()
defer d.lock.Unlock()
_, err := os.Stat(filename)
if err != nil {
return probe.NewError(err)
_, e := os.Stat(filename)
if e != nil {
return probe.NewError(e)
}
fileData, err := ioutil.ReadFile(filename)
if err != nil {
return probe.NewError(err)
fileData, e := ioutil.ReadFile(filename)
if e != nil {
return probe.NewError(e)
}
if runtime.GOOS == "windows" {
@ -235,18 +266,18 @@ func (d *config) Load(filename string) *probe.Error {
return probe.NewError(fmt.Errorf("Argument struct [%s] does not contain field \"Version\".", st.Name()))
}
err = json.Unmarshal(fileData, d.data)
if err != nil {
switch err := err.(type) {
e = json.Unmarshal(fileData, d.data)
if e != nil {
switch e := e.(type) {
case *json.SyntaxError:
return probe.NewError(FormatJSONSyntaxError(bytes.NewReader(fileData), err))
return probe.NewError(FormatJSONSyntaxError(bytes.NewReader(fileData), e))
default:
return probe.NewError(err)
return probe.NewError(e)
}
}
if err := CheckData(d.data); err != nil {
return err.Trace()
return err.Trace(filename)
}
if (*d).Version() != f.Value() {

@ -32,6 +32,21 @@ type MySuite struct{}
var _ = Suite(&MySuite{})
func (s *MySuite) TestSaveFailOnDir(c *C) {
defer os.RemoveAll("test.json")
e := os.MkdirAll("test.json", 0644)
c.Assert(e, IsNil)
type myStruct struct {
Version string
}
saveMe := myStruct{"1"}
config, err := quick.New(&saveMe)
c.Assert(err, IsNil)
c.Assert(config, Not(IsNil))
err = config.Save("test.json")
c.Assert(err, Not(IsNil))
}
func (s *MySuite) TestCheckData(c *C) {
err := quick.CheckData(nil)
c.Assert(err, Not(IsNil))
@ -69,7 +84,8 @@ func (s *MySuite) TestVersion(c *C) {
config, err := quick.New(&saveMe)
c.Assert(err, IsNil)
c.Assert(config, Not(IsNil))
config.Save("test.json")
err = config.Save("test.json")
c.Assert(err, IsNil)
valid, err := quick.CheckVersion("test.json", "1")
c.Assert(err, IsNil)
@ -92,19 +108,56 @@ func (s *MySuite) TestSaveLoad(c *C) {
config, err := quick.New(&saveMe)
c.Assert(err, IsNil)
c.Assert(config, Not(IsNil))
config.Save("test.json")
err = config.Save("test.json")
c.Assert(err, IsNil)
loadMe := myStruct{Version: "1"}
newConfig, err := quick.New(&loadMe)
c.Assert(err, IsNil)
c.Assert(newConfig, Not(IsNil))
err = newConfig.Load("test.json")
c.Assert(err, IsNil)
c.Assert(config.Data(), DeepEquals, newConfig.Data())
c.Assert(config.Data(), DeepEquals, &loadMe)
mismatch := myStruct{"1.1", "guest", "nopassword", []string{"Work", "Documents", "Music"}}
c.Assert(newConfig.Data(), Not(DeepEquals), &mismatch)
}
func (s *MySuite) TestSaveBackup(c *C) {
defer os.RemoveAll("test.json")
defer os.RemoveAll("test.json.old")
type myStruct struct {
Version string
User string
Password string
Folders []string
}
saveMe := myStruct{"1", "guest", "nopassword", []string{"Work", "Documents", "Music"}}
config, err := quick.New(&saveMe)
c.Assert(err, IsNil)
c.Assert(config, Not(IsNil))
err = config.Save("test.json")
c.Assert(err, IsNil)
loadMe := myStruct{Version: "1"}
newConfig, err := quick.New(&loadMe)
c.Assert(err, IsNil)
c.Assert(newConfig, Not(IsNil))
newConfig.Load("test.json")
err = newConfig.Load("test.json")
c.Assert(err, IsNil)
c.Assert(config.Data(), DeepEquals, newConfig.Data())
c.Assert(config.Data(), DeepEquals, &loadMe)
mismatch := myStruct{"1.1", "guest", "nopassword", []string{"Work", "Documents", "Music"}}
c.Assert(newConfig.Data(), Not(DeepEquals), &mismatch)
config, err = quick.New(&mismatch)
c.Assert(err, IsNil)
c.Assert(config, Not(IsNil))
err = config.Save("test.json")
c.Assert(err, IsNil)
}
func (s *MySuite) TestDiff(c *C) {

16
vendor/vendor.json vendored

@ -39,8 +39,8 @@
},
{
"path": "github.com/minio/minio-xl/pkg/atomic",
"revision": "008404af67dcf66bdde580245cd43951b425ed39",
"revisionTime": "2015-11-17T16:21:42-08:00"
"revision": "69c47f638917ab1cb9e24649c84ac38e6f1891b8",
"revisionTime": "2016-01-14T18:12:05-08:00"
},
{
"path": "github.com/minio/minio-xl/pkg/cpu",
@ -49,13 +49,13 @@
},
{
"path": "github.com/minio/minio-xl/pkg/crypto/sha256",
"revision": "a4e6504a5f94cf43bdbe3dec1a622317031b145d",
"revisionTime": "2015-11-14T00:48:52-08:00"
"revision": "69c47f638917ab1cb9e24649c84ac38e6f1891b8",
"revisionTime": "2016-01-14T18:12:05-08:00"
},
{
"path": "github.com/minio/minio-xl/pkg/crypto/sha512",
"revision": "a4e6504a5f94cf43bdbe3dec1a622317031b145d",
"revisionTime": "2015-11-14T00:48:52-08:00"
"revision": "69c47f638917ab1cb9e24649c84ac38e6f1891b8",
"revisionTime": "2016-01-14T18:12:05-08:00"
},
{
"path": "github.com/minio/minio-xl/pkg/minhttp",
@ -69,8 +69,8 @@
},
{
"path": "github.com/minio/minio-xl/pkg/quick",
"revision": "008404af67dcf66bdde580245cd43951b425ed39",
"revisionTime": "2015-11-17T16:21:42-08:00"
"revision": "69c47f638917ab1cb9e24649c84ac38e6f1891b8",
"revisionTime": "2016-01-14T18:12:05-08:00"
},
{
"path": "github.com/rs/cors",

Loading…
Cancel
Save