utils

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv added in v0.5.0

func GetEnv(envVar string, defaultValue string) string

GetEnv is a convenience wrapper for os.Getenv() with additional default value return when empty or unset

func GetIPFromContext

func GetIPFromContext(ctx context.Context) net.Addr

GetIPFromContext obtains the IP address of the caller from the context.

func GetLastChunkOfSlashed

func GetLastChunkOfSlashed(s string) string

GetLastChunkOfSlashed splits a string by slash and returns the last chunk.

func GetTrafficTargetName added in v0.4.0

func GetTrafficTargetName(name string, srcSvc service.MeshService, destSvc service.MeshService) string

GetTrafficTargetName returns the name for a TrafficTarget with the given source and destination.

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 IsValidUUID

func IsValidUUID(uuid string) bool

IsValidUUID validates a UUID

func K8sSvcToMeshSvc added in v0.4.0

func K8sSvcToMeshSvc(svc *corev1.Service) service.MeshService

K8sSvcToMeshSvc converts a Kubernetes service to a MeshService.

func NewGrpc

func NewGrpc(serverType string, port int, certPem, keyPem, rootCertPem []byte) (*grpc.Server, net.Listener, error)

NewGrpc creates a new gRPC server

func NewUUIDStr

func NewUUIDStr() string

NewUUIDStr creates a new string UUID.

func PrettyJSON

func PrettyJSON(js []byte, prefix string) ([]byte, error)

PrettyJSON Unmarshals and Marshall again with Indent so it is human readable

func ValidateClient

func ValidateClient(ctx context.Context, allowedCommonNames map[string]interface{}) (certificate.CommonName, error)

ValidateClient ensures that the connected client is authorized to connect to the gRPC server.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL