utils

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNonExistingFolder

func CreateNonExistingFolder(path string, mode fs.FileMode) error

func FileExists

func FileExists(filename string) bool

func FormatFilePath

func FormatFilePath(path string) string

func GenerateCSRAndPrivateKey

func GenerateCSRAndPrivateKey(privateKey, keyType, domain string, SAN []string) (string, []byte, error)

GenerateCSRAndPrivateKey generates a Certificate Signing Request (CSR) and a private key.

func GenerateFingerprint

func GenerateFingerprint(content []byte) string

func GetKeyType

func GetKeyType(keyTypeStr string) (certcrypto.KeyType, error)

GetKeyType the type from which private keys should be generated.

func RandomStringCrypto

func RandomStringCrypto(length int) (string, error)

func RandomWeekdayBeforeExpiration

func RandomWeekdayBeforeExpiration(expiration time.Time, minDays, maxDays int) time.Time

Function to generate a random weekday within a given range before an expiration date

func RequestLogHook

func RequestLogHook(logger *logrus.Logger) retryablehttp.RequestLogHook

RequestLogHook logs outgoing HTTP requests

func ResponseLogHook

func ResponseLogHook(logger *logrus.Logger, logJSONBody bool) retryablehttp.ResponseLogHook

ResponseLogHook logs the response status code and body

func ResponseLogHookDebug

func ResponseLogHookDebug(logger *logrus.Logger) retryablehttp.ResponseLogHook

ResponseLogHookDebug logs all responses with full details

func SHA1Hash

func SHA1Hash(content string) string

Get sha1 from string

func SanitizedDomain

func SanitizedDomain(logger log.Logger, domain string) string

SanitizedDomain Make sure no funny chars are in the cert names (like wildcards ;)).

func SetTLSConfig

func SetTLSConfig(cert string, key string, ca string, insecure bool) (*tls.Config, error)

func StructToMapInterface

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

func ValidateLabels

func ValidateLabels(labels string) (errors []error)

func ValidateRenewalDays

func ValidateRenewalDays(value string) (int, int, error)

Types

type CustomTextFormatter

type CustomTextFormatter struct {
	TimestampFormat  string
	CallerPrettyfier func(*runtime.Frame) (string, string)
}

CustomTextFormatter is a custom logrus formatter

func (*CustomTextFormatter) Format

func (f *CustomTextFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format implements the logrus.Formatter interface

type CustomWriter

type CustomWriter struct {
	Writer io.Writer
}

Custom Writer to block INFO messages containg [DEBUG] in message

func (*CustomWriter) Write

func (cw *CustomWriter) Write(p []byte) (n int, err error)

type DebugLevelHook

type DebugLevelHook struct {
	Logger *logrus.Logger
}

Hook to redirect logs with message starting with [DEBUG] from INFO to DEBUG level

func (*DebugLevelHook) Fire

func (hook *DebugLevelHook) Fire(entry *logrus.Entry) error

func (*DebugLevelHook) Levels

func (hook *DebugLevelHook) Levels() []logrus.Level

type UTCFormatter

type UTCFormatter struct {
	logrus.Formatter
}

func (UTCFormatter) Format

func (u UTCFormatter) Format(e *logrus.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

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