utils

package
v0.0.0-...-949823d Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultKubeClusterDomain is the default value of KubeClusterDomain.
	DefaultKubeClusterDomain = "cluster.local"
)
View Source
const (
	DotDelimiter = "."
)
View Source
const (
	// HostIPEnvVar is the environment variable to override host's chosen IP address.
	HostIPEnvVar = "DAPR_HOST_IP"
)

Variables

View Source
var (
	KubeConfigVar = "KUBE_CONFIG"
)

Functions

func ComponentLogName

func ComponentLogName(name, typ, version string) string

ComponentLogName returns the name of a component that can be used in logging.

func Contains

func Contains[T comparable](s []T, v T) bool

Contains reports whether v is present in s. Similar to https://pkg.go.dev/golang.org/x/exp/slices#Contains.

func ContainsPrefixed

func ContainsPrefixed(prefixes []string, v string) bool

ContainsPrefixed reports whether v is prefixed by any of the strings in s.

func Filter

func Filter[T any](items []T, test func(item T) bool) []T

Filter returns a new slice containing all items in the given slice that satisfy the given test.

func GetConfig

func GetConfig() *rest.Config

GetConfig gets a kubernetes rest config.

func GetEnvOrElse

func GetEnvOrElse(name, orElse string) string

GetEnvOrElse get the value from the OS environment or use the else value if variable is not present.

func GetHostAddress

func GetHostAddress() (string, error)

GetHostAddress selects a valid outbound IP address for the host.

func GetIntValOrDefault

func GetIntValOrDefault(val int, defaultValue int) int

GetIntValOrDefault returns an int value if greater than 0 OR default value.

func GetKubeClient

func GetKubeClient() *kubernetes.Clientset

GetKubeClient gets a kubernetes client.

func GetKubeClusterDomain

func GetKubeClusterDomain() (string, error)

GetKubeClusterDomain search KubeClusterDomain value from /etc/resolv.conf file.

func GetNamespaceOrDefault

func GetNamespaceOrDefault(defaultNamespace string) string

GetNamespaceOrDefault returns the namespace for Dapr, or the default namespace if it is not set.

func IsSocket

func IsSocket(f fs.FileInfo) bool

IsSocket returns if the given file is a unix socket.

func MapToSlice

func MapToSlice[T comparable, V any](m map[T]V) []T

MapToSlice is the inversion of SliceToMap. Order is not guaranteed as map retrieval order is not.

func ParseServiceAddr

func ParseServiceAddr(val string) []string

func PopulateMetadataForBulkPublishEntry

func PopulateMetadataForBulkPublishEntry(reqMeta, entryMeta map[string]string) map[string]string

func SetEnvVariables

func SetEnvVariables(variables map[string]string) error

SetEnvVariables set variables to environment.

func SocketExists

func SocketExists(socketPath string) bool

SocketExists returns true if the file in that path is an unix socket.

func UppercaseRequestMiddleware

func UppercaseRequestMiddleware(next http.Handler) http.Handler

UppercaseRequestMiddleware is a HTTP middleware that transforms the request body to uppercase

func UppercaseResponseMiddleware

func UppercaseResponseMiddleware(next http.Handler) http.Handler

UppercaseResponseMiddleware is a HTTP middleware that transforms the response body to uppercase

Types

This section is empty.

Jump to

Keyboard shortcuts

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