mirror of
https://github.com/hanzoai/kms-operator.git
synced 2026-10-30 18:32:57 +00:00
The group moved to kms.hanzo.ai/v1 here already, which is the right name — but it is still a compile-time constant, so this binary can serve a Hanzo install and no other. A Lux cluster needs kms.lux.cloud and there is no way to ask for it short of a rebuild. SetGroup makes it an argument behind --api-group, defaulting to kms.hanzo.ai, the way hanzoai/operator and luxfi/operator already take theirs. Registration moves out of init and into main, after the flag is read. The SchemeBuilder captures its GroupVersion when the types register, so registering first and setting the group afterwards leaves the scheme on one group while the manager watches another. That controller starts clean, logs nothing, and never sees an object — it reads as "no work to do" rather than as a misconfiguration, so the ordering is asserted in a test rather than left to whoever edits main next. Co-authored-by: Hanzo Dev <[email protected]>
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package v1
|
|
|
|
import "testing"
|
|
|
|
// One binary, any universe. The group was a compile-time constant, so a Lux
|
|
// install could not be served without a rebuild.
|
|
func TestSetGroupFollowsTheUniverse(t *testing.T) {
|
|
orig := GroupVersion
|
|
defer func() { GroupVersion = orig; SchemeBuilder.GroupVersion = orig }()
|
|
|
|
if GroupVersion.Group != DefaultGroup || GroupVersion.Version != Version {
|
|
t.Fatalf("default is %s, want %s/%s", GroupVersion, DefaultGroup, Version)
|
|
}
|
|
for _, g := range []string{"kms.hanzo.ai", "kms.lux.cloud", "kms.zoo.cloud"} {
|
|
SetGroup(g)
|
|
if GroupVersion.Group != g {
|
|
t.Errorf("SetGroup(%q) left the group at %q", g, GroupVersion.Group)
|
|
}
|
|
if GroupVersion.Version != Version {
|
|
t.Errorf("SetGroup(%q) changed the version to %q", g, GroupVersion.Version)
|
|
}
|
|
}
|
|
}
|
|
|
|
// The SchemeBuilder captures its GroupVersion when the types register, so a
|
|
// SetGroup that did not carry through would leave the scheme on one group while
|
|
// the manager watched another. That controller starts clean, logs nothing and
|
|
// never sees an object — which reads as "no work to do" rather than as a
|
|
// misconfiguration, and is why the ordering is asserted rather than remembered.
|
|
func TestSetGroupCarriesThroughToTheSchemeBuilder(t *testing.T) {
|
|
orig := GroupVersion
|
|
defer func() { GroupVersion = orig; SchemeBuilder.GroupVersion = orig }()
|
|
|
|
SetGroup("kms.lux.cloud")
|
|
if SchemeBuilder.GroupVersion != GroupVersion {
|
|
t.Errorf("builder on %s, group on %s", SchemeBuilder.GroupVersion, GroupVersion)
|
|
}
|
|
}
|
|
|
|
// An empty flag means unset, not the empty group: a scheme registered under ""
|
|
// matches nothing.
|
|
func TestAnEmptyGroupIsIgnored(t *testing.T) {
|
|
orig := GroupVersion
|
|
defer func() { GroupVersion = orig; SchemeBuilder.GroupVersion = orig }()
|
|
|
|
SetGroup("kms.lux.cloud")
|
|
SetGroup("")
|
|
if GroupVersion.Group != "kms.lux.cloud" {
|
|
t.Errorf("an empty SetGroup changed the group to %q", GroupVersion.Group)
|
|
}
|
|
}
|