Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Make sure we use a random fs-name
Browse files Browse the repository at this point in the history
We were getting fs-name clashes due to the deterministic random number
generator. As such, we had fs-ansible failures due to the same fs_name
being used in two places.
  • Loading branch information
JohnGarbutt committed Sep 2, 2019
1 parent 6c77f1a commit 84bd249
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/pkg/filesystem_impl/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/RSE-Cambridge/data-acc/internal/pkg/datamodel"
"github.com/RSE-Cambridge/data-acc/internal/pkg/filesystem"
"math/rand"
"time"
)

func NewFileSystemProvider(ansible filesystem.Ansible) filesystem.Provider {
Expand All @@ -17,10 +18,13 @@ type fileSystemProvider struct {

const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

var source = rand.NewSource(time.Now().UnixNano())
var randGenerator = rand.New(source)

func GetNewUUID() string {
b := make([]byte, 8)
for i := range b {
b[i] = letters[rand.Int63()%int64(len(letters))]
b[i] = letters[randGenerator.Int63()%int64(len(letters))]
}
return string(b)
}
Expand Down

0 comments on commit 84bd249

Please sign in to comment.