mirror of
https://github.com/lukaszraczylo/kubemirror.git
synced 2026-07-01 04:45:09 +00:00
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.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user