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 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 ProtoToYAML(m protoreflect.ProtoMessage) ([]byte, error)
- func SvcAccountToK8sSvcAccount(svcAccount *corev1.ServiceAccount) identity.K8sServiceAccount
- func ValidateClient(ctx context.Context) (certificate.CommonName, certificate.SerialNumber, error)
- func YAMLToProto(configYAML []byte, message protoreflect.ProtoMessage) 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 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 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) (certificate.CommonName, certificate.SerialNumber, error)
ValidateClient ensures that the connected client is authorized to connect to the gRPC server.
func YAMLToProto ¶ added in v1.2.0
func YAMLToProto(configYAML []byte, message protoreflect.ProtoMessage) error
YAMLToProto converts yaml to the provided proto message.
Types ¶
This section is empty.