mirror of
https://github.com/lukaszraczylo/kubemirror.git
synced 2026-06-30 01:25:02 +00:00
3628929871
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.
19 lines
771 B
Go
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
|
|
}
|