Merge pull request #1599 from hashicorp/use-go-uuid

Use go-uuid's GenerateUUID in PutWAL and discard logical.UUID()
This commit is contained in:
Vishal Nayak 2016-07-13 11:36:28 -06:00 committed by GitHub
commit e5a6a5e758
2 changed files with 2 additions and 22 deletions

View file

@ -5,6 +5,7 @@ import (
"strings"
"time"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/logical"
)
@ -43,7 +44,7 @@ func PutWAL(s logical.Storage, kind string, data interface{}) (string, error) {
return "", err
}
id, err := logical.UUID()
id, err := uuid.GenerateUUID()
if err != nil {
return "", err
}

View file

@ -1,21 +0,0 @@
package logical
import (
"crypto/rand"
"fmt"
"time"
)
// UUID returns a UUID.
func UUID() (string, error) {
unix := uint32(time.Now().UTC().Unix())
var b [12]byte
if _, err := rand.Read(b[:]); err != nil {
return "", err
}
return fmt.Sprintf("%08x-%04x-%04x-%04x-%04x%08x",
unix, b[0:2], b[2:4], b[4:6], b[6:8], b[8:]),
nil
}