Documentation
¶
Overview ¶
Package utils provides generic utility routines used within OSM.
Index ¶
- func GetEnv(envVar string, defaultValue string) string
- func GetIPFromContext(ctx context.Context) net.Addr
- func GetLastChunkOfSlashed(s string) string
- func GetTrafficTargetName(name string, srcSvc service.MeshService, destSvc service.MeshService) string
- func GrpcServe(ctx context.Context, grpcServer *grpc.Server, lis net.Listener, ...)
- func HashFromString(s string) (uint64, error)
- func K8sSvcToMeshSvc(svc *corev1.Service) service.MeshService
- func NewGrpc(serverType string, port int, certPem, keyPem, rootCertPem []byte) (*grpc.Server, net.Listener, error)
- func PrettyJSON(js []byte, prefix string) ([]byte, error)
- func ProtoToYAML(m protoreflect.ProtoMessage) ([]byte, error)
- func SvcAccountToK8sSvcAccount(svcAccount *corev1.ServiceAccount) identity.K8sServiceAccount
- func ValidateClient(ctx context.Context, allowedCommonNames map[string]interface{}) (certificate.CommonName, certificate.SerialNumber, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEnv ¶ added in v0.5.0
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 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 HashFromString ¶ added in v0.9.0
HashFromString calculates an FNV-1 hash from a given string, returns it as a uint64 and error, if any
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 PrettyJSON ¶
PrettyJSON Unmarshals and Marshall again with Indent so it is human readable
func ProtoToYAML ¶ added in v0.10.0
func ProtoToYAML(m protoreflect.ProtoMessage) ([]byte, error)
ProtoToYAML converts a Proto message to it's YAML representation in bytes
func SvcAccountToK8sSvcAccount ¶ added in v0.8.0
func SvcAccountToK8sSvcAccount(svcAccount *corev1.ServiceAccount) identity.K8sServiceAccount
SvcAccountToK8sSvcAccount converts a Kubernetes service to a MeshService.
func ValidateClient ¶
func ValidateClient(ctx context.Context, allowedCommonNames map[string]interface{}) (certificate.CommonName, certificate.SerialNumber, error)
ValidateClient ensures that the connected client is authorized to connect to the gRPC server.
Types ¶
This section is empty.