utils

package
v1.4.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckUntilTimeout

func CheckUntilTimeout(ctx context.Context, interval time.Duration, check func() bool) bool

CheckUntilTimeout Polls the check function until the context expires, in which case it returns false.

func CheckUntilTimeoutWithErr

func CheckUntilTimeoutWithErr(ctx context.Context, interval time.Duration, check func() (bool, error)) (bool, error)

CheckUntilTimeoutWithErr does the same as CheckUntilTimeout but requires the check function returns (bool, error), and will return an error immediately if the check function returns an error.

func GenerateCA

func GenerateCA(name, commonName string) (string, string, error)

GenerateCA generates a CA certificate and key.

func GenerateCert

func GenerateCert(name, commonName string, dnsNames, nodeIDs []string) (string, string, error)

GenerateCert generates a private and public key for testing in the directory specified.

func GenerateCertWithCA

func GenerateCertWithCA(name, caKeyPath, caCrtPath, commonName string, dnsNames, nodeIDs []string) (string, string, error)

GenerateCertWithCA generates a private and public key for testing in the directory specified using the ca specified.

func GenerateRSAPair

func GenerateRSAPair() (string, string, error)

func GetFreeTCPPort

func GetFreeTCPPort() (int, error)

Types

type TestLogWriter

type TestLogWriter struct {
	Lock   *sync.RWMutex
	Buffer *bytes.Buffer
}

testLogWriter provides a threadsafe way of reading and writing logs to a buffer.

func NewTestLogWriter

func NewTestLogWriter() *TestLogWriter

func (*TestLogWriter) String

func (lw *TestLogWriter) String() string

func (*TestLogWriter) Write

func (lw *TestLogWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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