Documentation ¶
Overview ¶
Package utils provides generic utility routines used within FSM.
Index ¶
- func GetEnv(envVar string, defaultValue string) string
- func GetIPFromContext(ctx context.Context) net.Addr
- func GetLastChunkOfSlashed(s string) string
- func GrpcServe(ctx context.Context, grpcServer *grpc.Server, lis net.Listener, ...)
- func HashFromString(s string) (uint64, error)
- func NewGrpc(serverType string, port int, certPem, keyPem, rootCertPem []byte) (*grpc.Server, net.Listener, error)
- func PrettyJSON(js []byte, prefix string) ([]byte, error)
- func SvcAccountToK8sSvcAccount(svcAccount *corev1.ServiceAccount) identity.K8sServiceAccount
- func ValidateClient(ctx context.Context) (certificate.CommonName, certificate.SerialNumber, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEnv ¶
GetEnv is a convenience wrapper for os.Getenv() with additional default value return when empty or unset
func GetIPFromContext ¶
GetIPFromContext obtains the IP address of the caller from the context.
func GetLastChunkOfSlashed ¶
GetLastChunkOfSlashed splits a string by slash and returns the last chunk.
func GrpcServe ¶
func GrpcServe(ctx context.Context, grpcServer *grpc.Server, lis net.Listener, cancel context.CancelFunc, serverType string, errorCh chan interface{})
GrpcServe starts the gRPC server passed.
func HashFromString ¶
HashFromString calculates an FNV-1 hash from a given string, returns it as a uint64 and error, if any
func NewGrpc ¶
func NewGrpc(serverType string, port int, certPem, keyPem, rootCertPem []byte) (*grpc.Server, net.Listener, error)
NewGrpc creates a new gRPC server
func PrettyJSON ¶
PrettyJSON Unmarshals and Marshall again with Indent so it is human readable
func SvcAccountToK8sSvcAccount ¶
func SvcAccountToK8sSvcAccount(svcAccount *corev1.ServiceAccount) identity.K8sServiceAccount
SvcAccountToK8sSvcAccount converts a Kubernetes service to a MeshService.
func ValidateClient ¶
func ValidateClient(ctx context.Context) (certificate.CommonName, certificate.SerialNumber, error)
ValidateClient ensures that the connected client is authorized to connect to the gRPC server.
Types ¶
This section is empty.