negotools

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 16 Imported by: 0

README

ne-go-tools

A collection for modules and convenience functions for go development.

These functions were primarily written during the development of different go based operators and other product components, so we collect them here to avoid duplication.

They were selected by immediate needs and anyone should feel free to add similar tools they feel might be useful to others.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CRC32Checksum

func CRC32Checksum(s string) string

Calculates the CRC32 checksum (using the ISO 3309-HDLC polynomial setting) of a string and returns the resulting number as uppercase HEX string.

func CheckGetEnvBool added in v0.2.0

func CheckGetEnvBool(key string) (value bool, err error)

func CheckGetEnvFloat added in v0.2.0

func CheckGetEnvFloat(key string) (value float64, err error)

func CheckGetEnvInt added in v0.2.0

func CheckGetEnvInt(key string) (value int, err error)

func CheckGetEnvString added in v0.2.0

func CheckGetEnvString(key string) (value string, err error)

func CheckGetEnvUInt added in v0.2.0

func CheckGetEnvUInt(key string) (value uint, err error)

func GenerateConfigMap

func GenerateConfigMap(name, namespaceName string, data map[string]string,
) corev1.ConfigMap

func GenerateDeployment

func GenerateDeployment(config DeploymentConfig) appsv1.Deployment

use a struct to avoid mistakes in the order of arguments and keep things read- and debugable

func GenerateExternalSecret

func GenerateExternalSecret(
	name, namespace, secretStoreName, secretStoreKind, targetSecretName, remoteSecretName string,
	refreshInterval metav1.Duration,
	externalSecretKeyMapping map[string]string,
) externalsecretsv1alpha1.ExternalSecret

func GenerateIngress

func GenerateIngress(
	name, namespace, dnsUri, ingressBaseUrl, serviceName, path, ingressClassName string,
	port int32, pathType networking.PathType,
) networking.Ingress

func GeneratePassword

func GeneratePassword(length uint, excludeAmbiguousChars bool) (password string, err error)

Generates a password of given length, optionally in-/excluding ambigous characters ("<>[](){}:;'/|\\,") which can cause issues in some applications

func GeneratePushSecret

func GeneratePushSecret(
	pushSecretName, targetSecretName, sourceSecretName, namespaceName string,
	secretStoreName, secretStoreKind string, keys []string, refreshInterval metav1.Duration,
) externalsecretsv1alpha1.PushSecret

func GenerateSecret

func GenerateSecret(
	name, namespaceName string, data map[string]string,
) corev1.Secret

func GetFunctionName

func GetFunctionName(functionLvl int) string

GetFunction feturns the function name by functionLvl. 1 = one level up, 2 = two levels up from current function

func LogDebug

func LogDebug(message string, fields ...interface{})

debugLog logs debug messages with contextual information.

func LogError

func LogError(message string, err error, fields ...interface{})

LogError logs an error with contextual information.

func LogInfo

func LogInfo(message string, fields ...interface{})

LogInfo logs info messages with contextual information.

func LogTrace added in v0.1.1

func LogTrace(message string, fields ...interface{})

debugLog logs debug messages with contextual information.

func LogWarning

func LogWarning(message string, err error, fields ...interface{})

LogWarning logs an warning with contextual information.

func SetLoglevel added in v0.1.1

func SetLoglevel(logLevel string) (err error)

Types

type DeploymentConfig

type DeploymentConfig struct {
	Name                       string
	Namespace                  string
	Volumes                    []corev1.Volume
	ImagePullSecretName        string
	ContainerName              string
	Image                      string
	PortName                   string
	EnvFromSecretNames         []string
	EnvFromConfigMapNames      []string
	VolumeMounts               []corev1.VolumeMount
	ImagePullPolicy            corev1.PullPolicy
	ContainerPort              int32
	DefaultConfigMapVolumeMode int32
	Replicas                   int32
	EnvVarData                 map[string]string
	PodLabels                  map[string]string
	MatchLabels                map[string]string
	CpuRequestMilli            int64
	CpuLimitMilli              int64
	MemoryRequestMi            int64
	MemoryLimitMi              int64
	LivenessProbeSpec          ProbeSpec
	ReadinessProbeSpec         ProbeSpec
}

type ProbeSpec

type ProbeSpec struct {
	HttpGetPath         string
	HttpGetPort         int32
	InitialDelaySeconds int32
	TimeoutSeconds      int32
	PeriodSeconds       int32
	FailureThreshold    int32
	SuccessThreshold    int32
}

Jump to

Keyboard shortcuts

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