utils

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: Apache-2.0 Imports: 24 Imported by: 3

Documentation

Overview

Package utils provides generic utility routines used within OSM.

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 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

func HashFromString(s string) (uint64, error)

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

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

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.

Jump to

Keyboard shortcuts

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