{"modulePath":"github.com/cobaltcore-dev/openstack-hypervisor-operator","version":"v1.4.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\n## Variables\n\n```go\nvar (\n\tLifecycleEnabledPredicate = predicate.NewPredicateFuncs(func(object client.Object) bool {\n\t\tif hv, ok := object.(*kvmv1.Hypervisor); ok {\n\t\t\treturn hv.Spec.LifecycleEnabled\n\t\t}\n\t\treturn true\n\t})\n)\n```\n\n```go\nvar StatusPatchBackoff = wait.Backoff{\n\tSteps:    10,\n\tDuration: 50 * time.Millisecond,\n\tFactor:   2.0,\n\tJitter:   0.2,\n}\n```\nStatusPatchBackoff is a retry backoff for status patches that may conflict with other controllers. Uses exponential backoff with more retries than the default to handle high contention scenarios.\n\n## Functions\n\n```go\nfunc ConditionFromStatus(c metav1.Condition) *k8sacmetav1.ConditionApplyConfiguration\n```\nConditionFromStatus converts a single metav1.Condition into a \\*k8sacmetav1.ConditionApplyConfiguration, preserving all fields verbatim (including LastTransitionTime and ObservedGeneration).\n\nControllers must seed their apply-config payload with the conditions they own before mutating them. With +listType=map / +listMapKey=type on the CRD, SSA merges conditions by the \"type\" key: conditions owned by other field managers are left untouched, and conditions previously written by this field manager that are absent from the payload are pruned. Therefore each controller should include all conditions it has previously set — and only those — in every Apply call.\n\n```go\nfunc Difference[S ~[]E, E comparable](s1, s2 S) S\n```\nDifference returns all elements in s2 that are not in s1.\n\n```go\nfunc PatchHypervisorStatusWithRetry(ctx context.Context, c k8sclient.Client, name, fieldOwner string, updateFn func(*kvmv1.Hypervisor)) error\n```\nPatchHypervisorStatusWithRetry patches hypervisor status with retry on conflict. The updateFn receives a fresh copy of the hypervisor and should apply status changes to it. It re-fetches the resource before each retry attempt to get the latest resourceVersion.\n\n```go\nfunc SetApplyConfigurationStatusCondition(conditions *[]k8sacmetav1.ConditionApplyConfiguration, newCondition k8sacmetav1.ConditionApplyConfiguration)\n```\nSetApplyConfigurationStatusCondition sets the corresponding condition in conditions to newCondition. It mirrors the behaviour of k8s.io/apimachinery/pkg/api/meta.SetStatusCondition:\n\n 1. If a condition of the specified type does not exist, newCondition is appended. LastTransitionTime is set to now if not provided.\n 2. If a condition of the specified type already exists, all fields are updated. LastTransitionTime is updated to now (or the provided value) only when Status changes; otherwise the existing LastTransitionTime is preserved.\n\n","path":"github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/utils","name":"utils","synopsis":"","isRedistributable":true}
