woodpecker-autoscaler/internal/utils/utils.go
Tobias Trabelsi 6a63daab73
All checks were successful
Pipeline was successful
error handling in agent parsing
2023-11-10 21:14:49 +01:00

30 lines
521 B
Go

package utils
import (
"math/rand"
log "github.com/sirupsen/logrus"
)
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
}
func CheckError(err error, caller string) {
if err != nil {
log.WithFields(log.Fields{
"Caller": caller,
}).Warnf("Error from hetzner API: %s", err.Error())
}
}