utils

package
v0.0.0-...-d214319 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToFile

func AppendToFile(filePath, content string) error

func BytesToGB

func BytesToGB(size interface{}) int64

func DecryptAESCBC

func DecryptAESCBC(key, ciphertext string) (string, error)

func DeleteFile

func DeleteFile(file string) error

func EncryptAESCBC

func EncryptAESCBC(key, original string) (string, error)

func FormatHeaders

func FormatHeaders(headers http.Header, separator string) string

FormatHeaders processes a headers object plus a deliminator, returning a string

func LogGRPC

func LogGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

func ParseEndpoint

func ParseEndpoint(ep string) (string, string, error)

func RedactHeaders

func RedactHeaders(headers http.Header) (processedHeaders []string)

RedactHeaders processes a headers object, returning a redacted list

func RoundUpSize

func RoundUpSize(volumeSizeBytes int64, allocationUnitBytes int64) int64

RoundUpSize calculates how many allocation units are needed to accommodate a volume of given size. E.g. when user wants 1500Mi volume, while HuaweiCLoud EVS/SFS allocates volumes in Gi byte-sized chunks, RoundUpSize(1500 * 1024*1024, 1024*1024*1024) returns '2' (2 GiB is the smallest allocatable volume that can hold 1500MiB)

func Sha256

func Sha256(valueMap map[string]string) string

func WriteToFile

func WriteToFile(filePath, content string) error

Types

type LogRoundTripper

type LogRoundTripper struct {
	Rt http.RoundTripper
}

LogRoundTripper satisfies the http.RoundTripper interface and is used to customize the default http client RoundTripper to allow for logging.

func (*LogRoundTripper) RoundTrip

func (lrt *LogRoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip performs a round-trip HTTP request and logs relevant information about it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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