controllerutil

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationSpecHash    = "checksum/spec"
	AnnotationConfigHash  = "checksum/configuration"
	AnnotationRestartedAt = "kubectl.kubernetes.io/restartedAt"

	AnnotationStatefulSetVersion = "clickhouse.com/statefulset-version"
)
View Source
const (
	LabelAppKey         = "app"
	LabelAppK8sKey      = "app.kubernetes.io/name"
	LabelInstanceK8sKey = "app.kubernetes.io/instance"

	LabelRoleKey             = "clickhouse.com/role"
	LabelKeeperReplicaID     = "clickhouse.com/keeper-replica-id"
	LabelClickHouseShardID   = "clickhouse.com/shard-id"
	LabelClickHouseReplicaID = "clickhouse.com/replica-id"
)

Contains common labels keys and helpers to work with.

View Source
const (
	LabelKeeperValue       = "clickhouse-keeper"
	LabelKeeperAllReplicas = "all-replicas"

	LabelClickHouseValue = "clickhouse-server"
)

Variables

This section is empty.

Functions

func AddHashWithKeyToAnnotations

func AddHashWithKeyToAnnotations(obj client.Object, key string, specHash string)

AddHashWithKeyToAnnotations adds given spec hash to object's annotations with given key.

func AddObjectConfigHash

func AddObjectConfigHash(obj client.Object, hash string)

AddObjectConfigHash adds given config hash to object's annotations.

func AppRequirements

func AppRequirements(namespace, app string) *client.ListOptions

AppRequirements returns ListOptions to list resources of the given app.

func ApplyDefault

func ApplyDefault[T any](source *T, defaults T) error

ApplyDefault recursively applies default values from the 'defaults' struct to the zero-values 'source' struct fields.

func DeepHashObject

func DeepHashObject(objectToWrite any) (string, error)

DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes. (copied from Kubernetes, with changes).

func DeepHashResource

func DeepHashResource(obj client.Object, specFields []string) (string, error)

DeepHashResource writes specified resource's labels, annotations and spec fields to hash.

func ExecuteParallel

func ExecuteParallel[Item any, Id comparable, Tasks ~[]Item, Result any](
	tasks Tasks,
	f func(Item) (Id, Result, error),
) map[Id]ExecutionResult[Id, Result]

ExecuteParallel executes the given function 'f' in parallel for each item in 'tasks'. It does not use context, caller should ensure proper cancellation in the task.

func GeneratePassword

func GeneratePassword() string

GeneratePassword generates a random password of fixed length using a predefined alphabet.

func GetConfigHashFromObject

func GetConfigHashFromObject(found client.Object) string

GetConfigHashFromObject retrieves config hash from object's annotations.

func GetFunctionName

func GetFunctionName(temp any) string

GetFunctionName returns the name of the function passed as an argument.

func GetSpecHashFromObject

func GetSpecHashFromObject(found client.Object) string

GetSpecHashFromObject retrieves spec hash from object's annotations.

func MergeMaps

func MergeMaps[Value any](mapsToMerge ...map[string]Value) map[string]Value

MergeMaps merges multiple maps into a single map. If the same key exists in multiple maps, the value from the last map will be used.

func PathToName

func PathToName(path string) string

PathToName converts a filesystem-like path to a name by replacing '/' and '.' with '-'.

func Sha256Hash

func Sha256Hash(password []byte) string

Sha256Hash returns the SHA-256 hash of the given password as a hexadecimal string.

func ShouldEmitEvent

func ShouldEmitEvent(err error) bool

ShouldEmitEvent returns whether an error should trigger an event emission.

func SortKey

func SortKey[T any, V cmp.Ordered](slice []T, key func(T) V)

SortKey sorts a slice of any type T based on a key function that extracts an ordered value V from T.

func UpdateResult

func UpdateResult(result *ctrl.Result, update *ctrl.Result)

UpdateResult merges two ctrl.Result objects, choosing the most recent RequeueAfter duration.

Types

type ExecutionResult

type ExecutionResult[Id comparable, Result any] struct {
	Result Result
	Err    error
}

ExecutionResult holds the result of task execution along with any error encountered.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a Logger implementation using zap.Logger.

func NewLogger

func NewLogger(l *zap.Logger) Logger

NewLogger creates a new Logger.

func (Logger) Debug

func (l Logger) Debug(msg string, keysAndVals ...any)

Debug logs a debug message.

func (Logger) Error

func (l Logger) Error(err error, msg string, keysAndVals ...any)

Error logs an error message with an error.

func (Logger) Fatal

func (l Logger) Fatal(err error, msg string, keysAndVals ...any)

Fatal logs an error message and exists.

func (Logger) Info

func (l Logger) Info(msg string, keysAndVals ...any)

Info logs an info message.

func (Logger) Named

func (l Logger) Named(name string) Logger

Named creates a named child logger.

func (Logger) Panic

func (l Logger) Panic(err error, msg string, keysAndVals ...any)

Panic logs an error message and panics.

func (Logger) Warn

func (l Logger) Warn(msg string, keysAndVals ...any)

Warn logs a warning message.

func (Logger) With

func (l Logger) With(keysAndVals ...any) Logger

With creates a child logger with additional key-value pairs.

func (Logger) WithContext

func (l Logger) WithContext(ctx context.Context, object client.Object) Logger

WithContext creates a child logger with fields from the context and object.

Jump to

Keyboard shortcuts

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