headscale-operator/pkg/utils/utils.go
Guilhem Lettron 8f064a2890 Initial Commit 🎉
2022-06-23 16:15:33 +02:00

36 lines
620 B
Go

package utils
import (
"net"
"strconv"
"strings"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func SliptHostPort(hostport string) (string, int, error) {
host, sListenPort, err := net.SplitHostPort(hostport)
if err != nil {
return "", 0, err
}
listenPort, err := strconv.Atoi(sListenPort)
if err != nil {
return "", 0, err
}
return host, listenPort, nil
}
func IgnoreNotFound(err error) error {
status, ok := status.FromError(err)
if !ok {
return err
}
if (status.Code() == codes.NotFound) || strings.Contains(status.Message(), "not found") {
return nil
}
return err
}