Peter Kurfer
647f602c79
- added Core CRD to manage DB migrations & configuration, PostgREST and GoTrue (auth) - added APIGateway CRD to manage Envoy proxy - added Dashboard CRD to manage (so far) pg-meta and (soon) studio deployments - implemented basic Envoy control plane based on K8s watcher
33 lines
598 B
Go
33 lines
598 B
Go
package controller
|
|
|
|
import (
|
|
"bytes"
|
|
"math/rand/v2"
|
|
)
|
|
|
|
func GeneratePW(length uint, random *rand.Rand) []byte {
|
|
var (
|
|
builder = bytes.NewBuffer(nil)
|
|
alphabet = runes('a', 'z') + runes('A', 'Z') + runes('0', '9')
|
|
)
|
|
|
|
if random == nil {
|
|
random = rand.New(rand.NewPCG(0, 0))
|
|
}
|
|
|
|
for range length {
|
|
builder.WriteRune(rune(alphabet[random.IntN(len(alphabet))]))
|
|
}
|
|
|
|
return builder.Bytes()
|
|
}
|
|
|
|
func runes(start, end rune) string {
|
|
result := make([]rune, 0, int(end-start))
|
|
|
|
for current := start; current != end; current++ {
|
|
result = append(result, current)
|
|
}
|
|
|
|
return string(result)
|
|
}
|