Problem
Definitions.ByKind in generators/api/definition.go is keyed by kind name only:
for _, d:= range s.All {
s.ByKind[d.Name] = append(s.ByKind[d.Name], d)
}
When two unrelated API groups define the same kind name, they share a bucket. The next loop sorts the bucket and flags everything past index 0 as IsOldVersion, which is wrong when the entries belong to different groups.
Example HTML backend
Take TypedLocalObjectReference as a concrete case. It exists as two unrelated kinds:
core/v1.TypedLocalObjectReference
scheduling.k8s.io/v1alpha2.TypedLocalObjectReference
They share a name but are independent types. With name-only ByKind keying, the
generator treats them as versions of each other.
Master (buggy):
The scheduling.k8s.io/v1alpha2 page shows an "Other API versions of this object
exist: v1" alert linking to core/v1.TypedLocalObjectReference: a misleading
claim, since the two are independent kinds.
With the fix:
The misleading alert is gone. Each kind is treated as its own bucket.
Proposed fix
Key ByKind by (group, kind) instead of kind alone:
type byKindKey struct {
Group string
Kind string
}
type Definitions struct {
ByKind map[byKindKey]SortDefinitionsByVersion
...
}
FindNewestVersion(group, kind) already takes a group; manual filtering becomes unnecessary. Same v1.36 spec, after the fix: zero cross-group false positives.
PR follows.
Problem
Definitions.ByKindin generators/api/definition.go is keyed by kind name only:When two unrelated API groups define the same kind name, they share a bucket. The next loop sorts the bucket and flags everything past index 0 as IsOldVersion, which is wrong when the entries belong to different groups.
Example HTML backend
Take
TypedLocalObjectReferenceas a concrete case. It exists as two unrelated kinds:core/v1.TypedLocalObjectReferencescheduling.k8s.io/v1alpha2.TypedLocalObjectReferenceThey share a name but are independent types. With name-only
ByKindkeying, thegenerator treats them as versions of each other.
Master (buggy):
With the fix:
Proposed fix
Key
ByKindby(group, kind)instead ofkindalone:FindNewestVersion(group, kind)already takes a group; manual filtering becomes unnecessary. Same v1.36 spec, after the fix: zero cross-group false positives.PR follows.