moving random.go from utils

Closes #10962
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
This commit is contained in:
Srini Brahmaroutu
2015-02-26 18:31:18 +00:00
parent 21811f0786
commit 53ece336dc
5 changed files with 72 additions and 19 deletions
-16
View File
@@ -1,16 +0,0 @@
package utils
import (
"crypto/rand"
"encoding/hex"
"io"
)
func RandomString() string {
id := make([]byte, 32)
if _, err := io.ReadFull(rand.Reader, id); err != nil {
panic(err) // This shouldn't happen
}
return hex.EncodeToString(id)
}
+2 -1
View File
@@ -21,6 +21,7 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/docker/docker/autogen/dockerversion"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/common"
"github.com/docker/docker/pkg/fileutils"
"github.com/docker/docker/pkg/ioutils"
)
@@ -311,7 +312,7 @@ var globalTestID string
// new directory.
func TestDirectory(templateDir string) (dir string, err error) {
if globalTestID == "" {
globalTestID = RandomString()[:4]
globalTestID = common.RandomString()[:4]
}
prefix := fmt.Sprintf("docker-test%s-%s-", globalTestID, GetCallerName(2))
if prefix == "" {