util

package
v1.1.69 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 37 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// DefaultKeepAliveInterval - default duration to send keep alive pings
	DefaultKeepAliveInterval = 50 * time.Second
	// DefaultKeepAliveTimeout - default keepalive timeout
	DefaultKeepAliveTimeout = 10 * time.Second
)
View Source
const (
	// AmplifyCentral amplify central
	AmplifyCentral             = "Amplify Central"
	CentralHealthCheckEndpoint = "central"
)

Variables

This section is empty.

Functions

func CheckEmptyMapStringString

func CheckEmptyMapStringString(m map[string]string) map[string]string

CheckEmptyMapStringString creates a new empty map if the provided map is nil

func ComputeHash

func ComputeHash(data interface{}) (uint64, error)

ComputeHash - get the hash of the byte array sent in

func ComputeKIDFromDER

func ComputeKIDFromDER(publicKey []byte) (kid string, err error)

ComputeKIDFromDER - compute key ID for public key

func ConvertStringToUint

func ConvertStringToUint(val string) uint64

ConvertStringToUint -

func ConvertTimeToMillis

func ConvertTimeToMillis(tm time.Time) int64

ConvertTimeToMillis - convert to milliseconds

func ConvertToDomainNameCompliant

func ConvertToDomainNameCompliant(str string) string

ConvertToDomainNameCompliant - converts string to be domain name complaint

func ConvertUnitToString

func ConvertUnitToString(val uint64) string

ConvertUnitToString -

func CreateDirIfNotExist

func CreateDirIfNotExist(dirPath string)

CreateDirIfNotExist - Creates the directory with same permission as parent

func GetAgentDetailStrings

func GetAgentDetailStrings(h handler) map[string]string

GetAgentDetailStrings get all the values for the x-agent-details sub resource as string

func GetAgentDetails

func GetAgentDetails(h handler) map[string]interface{}

GetAgentDetails get all the values for the x-agent-details sub resource

func GetAgentDetailsValue

func GetAgentDetailsValue(h handler, key string) (string, error)

GetAgentDetailsValue gets a single string value fom the x-agent-details sub resource. Returns nil for error if x-agent-details does not exist. Returns errors if unable to perform type conversion. Returns an empty string if the value does not exist, or if there is an error.

func GetProxyURL

func GetProxyURL(fixedURL *url.URL) func(*http.Request) (*url.URL, error)

GetProxyURL - need to provide my own function (instead of http.ProxyURL()) to handle empty url. Returning nil means "no proxy"

func GetStringArrayFromMapInterface

func GetStringArrayFromMapInterface(key string, data map[string]interface{}) []string

GetStringArrayFromMapInterface - returns the validated string array for the map element

func GetStringFromMapInterface

func GetStringFromMapInterface(key string, data map[string]interface{}) string

GetStringFromMapInterface - returns the validated string for the map element

func GetSubResourceDetails added in v1.1.61

func GetSubResourceDetails(h handler) map[string]interface{}

func GetSubResourcePropertyValue

func GetSubResourcePropertyValue(h handler, subRes, key string) (string, error)

GetSubResourcePropertyValue gets a single string value fom the specified sub resource. Returns nil for error if specified does not exist. Returns errors if unable to perform type conversion. Returns an empty string if the value does not exist, or if there is an error.

func GetURLHostName

func GetURLHostName(urlString string) string

GetURLHostName - return the host name of the passed in URL

func HandleInterfaceFuncNotImplemented

func HandleInterfaceFuncNotImplemented(obj interface{}, funcName, interfaceName string)

HandleInterfaceFuncNotImplemented - use this function to recover from a panic due to an interface not being implemented

func IsItemInSlice

func IsItemInSlice(strSlice []string, item string) bool

IsItemInSlice - Returns true if the given item is in the string slice, strSlice should be sorted

func IsNil

func IsNil(v interface{}) bool

IsNil checks a value, or a pointer for nil

func IsNotTest

func IsNotTest() bool

IsNotTest determines if a test is running or not

func LoadEnvFromFile

func LoadEnvFromFile(filename string) error

LoadEnvFromFile - Loads the environment variables from a file

func MapStringInterfaceToStringString

func MapStringInterfaceToStringString(data map[string]interface{}) map[string]string

MapStringInterfaceToStringString - convert map[string]interface{} to map[string]string given the item can be a string

func MapStringStringToMapStringInterface

func MapStringStringToMapStringInterface(m map[string]string) map[string]interface{}

MapStringStringToMapStringInterface converts a map[string]string to map[string]interface{}

func MapsEqual added in v1.1.51

func MapsEqual(m1, m2 map[string]interface{}) bool

func MaskValue

func MaskValue(sensitiveData string) string

MaskValue - mask sensitive information with * (asterisk). Length of sensitiveData to match returning maskedValue

func MergeMapStringInterface

func MergeMapStringInterface(m ...map[string]interface{}) map[string]interface{}

MergeMapStringInterface - merges the provided maps. If duplicate keys are found across the maps, then the keys in map n will be overwritten in keys in map n+1

func MergeMapStringString

func MergeMapStringString(m ...map[string]string) map[string]string

MergeMapStringString - merges the provided maps. If duplicate keys are found across the maps, then the keys in map n will be overwritten in keys in map n+1.

func NormalizeNameForCentral added in v1.1.35

func NormalizeNameForCentral(str string) string

func ParseAddr

func ParseAddr(url *url.URL) string

ParseAddr - parse host:port from URL

func ParsePort

func ParsePort(url *url.URL) int

ParsePort - parse port from URL

func ParsePublicKey

func ParsePublicKey(publicKey []byte) (*rsa.PublicKey, error)

ParsePublicKey - parses the public key content

func ParsePublicKeyDER

func ParsePublicKeyDER(publicKey []byte) ([]byte, error)

ParsePublicKeyDER - parse DER block from public key

func PrettyPrint

func PrettyPrint(data interface{})

PrettyPrint - print the contents of the obj

func PrintDataInterface

func PrintDataInterface(data interface{})

PrintDataInterface - prints contents of the interface only if in debug mode

func ReadPrivateKeyFile

func ReadPrivateKeyFile(privateKeyFile, passwordFile string) (*rsa.PrivateKey, error)

ReadPrivateKeyFile - reads and parses the private key content

func ReadPublicKeyBytes

func ReadPublicKeyBytes(publicKeyFile string) ([]byte, error)

ReadPublicKeyBytes - reads the public key bytes from file

func RemoveDuplicateValuesFromStringSlice

func RemoveDuplicateValuesFromStringSlice(strSlice []string) []string

RemoveDuplicateValuesFromStringSlice - remove duplicate values from a string slice

func RemoveUnquotedSpaces

func RemoveUnquotedSpaces(s string) (string, error)

RemoveUnquotedSpaces - Remove all whitespace not between matching quotes

func SetAgentDetails

func SetAgentDetails(h handler, details map[string]interface{})

SetAgentDetails creates a new x-agent-details sub resource for the given resource.

func SetAgentDetailsKey

func SetAgentDetailsKey(h handler, key, value string) error

SetAgentDetailsKey sets a key value pair in the x-agent-details sub resource. If x-agent-details does not exist, it is created. If value is not a string or an int, an error will be returned.

func StringSliceContains

func StringSliceContains(items []string, s string) bool

StringSliceContains - does the given string slice contain the specified string?

func ToString

func ToString(v interface{}) string

ToString converts an interface{} to a string

Types

type Dialer

type Dialer interface {
	// Dial - interface used by libbeat for tcp network dial
	Dial(network string, addr string) (net.Conn, error)
	// DialContext - interface used by http transport
	DialContext(ctx context.Context, network string, addr string) (net.Conn, error)
	// GetProxyScheme() string
	GetProxyScheme() string
}

Dialer - interface for http dialer for proxy and single entry point

func NewDialer

func NewDialer(proxyURL *url.URL, singleEntryHostMap map[string]string) Dialer

NewDialer - creates a new dialer

type Encryptor

type Encryptor interface {
	Encrypt(str string) (string, error)
}

Encryptor is an interface for encrypting strings

func NewEncryptor

func NewEncryptor(key, alg, hash string) (Encryptor, error)

NewEncryptor creates a struct to handle encryption based on the provided key, algorithm, and hash.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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