2023-10-31 22:18:08 +00:00
|
|
|
package utils
|
|
|
|
|
2023-11-10 20:14:49 +00:00
|
|
|
import (
|
|
|
|
"math/rand"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
2023-10-31 22:18:08 +00:00
|
|
|
|
|
|
|
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
|
|
|
|
|
|
func RandStringBytes(n int) string {
|
|
|
|
b := make([]byte, n)
|
|
|
|
for i := range b {
|
|
|
|
b[i] = letterBytes[rand.Intn(len(letterBytes))]
|
|
|
|
}
|
|
|
|
return string(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BoolPointer(b bool) *bool {
|
|
|
|
return &b
|
|
|
|
}
|
2023-11-10 20:14:49 +00:00
|
|
|
|
|
|
|
func CheckError(err error, caller string) {
|
|
|
|
if err != nil {
|
|
|
|
log.WithFields(log.Fields{
|
|
|
|
"Caller": caller,
|
|
|
|
}).Warnf("Error from hetzner API: %s", err.Error())
|
|
|
|
}
|
|
|
|
}
|