mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
API emulation versioning honors cohabitating resources
This commit is contained in:
parent
1f7b707f26
commit
880e026a07
@ -130,13 +130,24 @@ func emulatedStorageVersion(binaryVersionOfResource schema.GroupVersion, example
|
|||||||
gvks, _, err := scheme.ObjectKinds(example)
|
gvks, _, err := scheme.ObjectKinds(example)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return schema.GroupVersion{}, err
|
return schema.GroupVersion{}, err
|
||||||
} else if len(gvks) == 0 {
|
}
|
||||||
// Probably shouldn't happen if err is non-nil
|
|
||||||
|
var gvk schema.GroupVersionKind
|
||||||
|
for _, item := range gvks {
|
||||||
|
if item.Group != binaryVersionOfResource.Group {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
gvk = item
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(gvk.Kind) == 0 {
|
||||||
return schema.GroupVersion{}, fmt.Errorf("object %T has no GVKs registered in scheme", example)
|
return schema.GroupVersion{}, fmt.Errorf("object %T has no GVKs registered in scheme", example)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VersionsForGroupKind returns versions in priority order
|
// VersionsForGroupKind returns versions in priority order
|
||||||
versions := scheme.VersionsForGroupKind(schema.GroupKind{Group: gvks[0].Group, Kind: gvks[0].Kind})
|
versions := scheme.VersionsForGroupKind(schema.GroupKind{Group: gvk.Group, Kind: gvk.Kind})
|
||||||
|
|
||||||
compatibilityVersion := effectiveVersion.MinCompatibilityVersion()
|
compatibilityVersion := effectiveVersion.MinCompatibilityVersion()
|
||||||
|
|
||||||
@ -148,7 +159,7 @@ func emulatedStorageVersion(binaryVersionOfResource schema.GroupVersion, example
|
|||||||
gvk := schema.GroupVersionKind{
|
gvk := schema.GroupVersionKind{
|
||||||
Group: gv.Group,
|
Group: gv.Group,
|
||||||
Version: gv.Version,
|
Version: gv.Version,
|
||||||
Kind: gvks[0].Kind,
|
Kind: gvk.Kind,
|
||||||
}
|
}
|
||||||
|
|
||||||
exampleOfGVK, err := scheme.New(gvk)
|
exampleOfGVK, err := scheme.New(gvk)
|
||||||
|
@ -245,7 +245,7 @@ func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource, ex
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
if backwardCompatibleInterface, ok := s.ResourceEncodingConfig.(CompatibilityResourceEncodingConfig); ok {
|
if backwardCompatibleInterface, ok := s.ResourceEncodingConfig.(CompatibilityResourceEncodingConfig); ok {
|
||||||
codecConfig.StorageVersion, err = backwardCompatibleInterface.BackwardCompatibileStorageEncodingFor(groupResource, example)
|
codecConfig.StorageVersion, err = backwardCompatibleInterface.BackwardCompatibileStorageEncodingFor(chosenStorageResource, example)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user