Files
kubemirror/pkg/controller/naming.go
T
lukaszraczylo 3628929871 refactor(controller): extract shared mirror-deletion and naming helpers
Replace the triplicated ownership-verified delete guard with deleteOwnedMirror, and hand-built controller-name strings with gvkControllerName. Use constants.Domain/ControllerName over magic strings and maps.Copy/Clone for plain copy loops. Behaviour-preserving; tests green.
2026-06-21 13:26:23 +01:00

19 lines
771 B
Go

// Package controller implements the kubemirror reconciliation logic.
package controller
import "k8s.io/apimachinery/pkg/runtime/schema"
// gvkControllerName builds the unique controller-runtime controller name for a
// GVK. Including version and group avoids collisions across API versions, e.g.
// "HorizontalPodAutoscaler.v1.autoscaling" or "Secret.v1." (empty group for
// core resources). Source and mirror reconcilers for the same GVK must differ,
// so mirror controllers get a "-mirror" suffix. This is the single source of
// truth for the convention shared by both reconcilers.
func gvkControllerName(gvk schema.GroupVersionKind, mirror bool) string {
name := gvk.Kind + "." + gvk.Version + "." + gvk.Group
if mirror {
name += "-mirror"
}
return name
}