cord-776 create build / runtime containers for autmation uservices
Change-Id: I246973192adef56a250ffe93a5f65fff488840c1
diff --git a/switchq/vendor/github.com/juju/utils/randomstring.go b/switchq/vendor/github.com/juju/utils/randomstring.go
new file mode 100644
index 0000000..662f514
--- /dev/null
+++ b/switchq/vendor/github.com/juju/utils/randomstring.go
@@ -0,0 +1,42 @@
+// Copyright 2015 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package utils
+
+import (
+ "math/rand"
+ "sync"
+ "time"
+)
+
+// Can be used as a sane default argument for RandomString
+var (
+ LowerAlpha = []rune("abcdefghijklmnopqrstuvwxyz")
+ UpperAlpha = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+ Digits = []rune("0123456789")
+)
+
+var (
+ randomStringMu sync.Mutex
+ randomStringRand *rand.Rand
+)
+
+func init() {
+ randomStringRand = rand.New(
+ rand.NewSource(time.Now().UnixNano()),
+ )
+}
+
+// RandomString will return a string of length n that will only
+// contain runes inside validRunes
+func RandomString(n int, validRunes []rune) string {
+ randomStringMu.Lock()
+ defer randomStringMu.Unlock()
+
+ runes := make([]rune, n)
+ for i := range runes {
+ runes[i] = validRunes[randomStringRand.Intn(len(validRunes))]
+ }
+
+ return string(runes)
+}