@@ -3,8 +3,11 @@ package filepath
3
3
4
4
import (
5
5
"k8s.io/apimachinery/pkg/runtime"
6
+ "k8s.io/apimachinery/pkg/runtime/serializer"
6
7
"k8s.io/apiserver/pkg/registry/generic"
7
8
"k8s.io/apiserver/pkg/registry/rest"
9
+ "k8s.io/apiserver/pkg/server/storage"
10
+ "k8s.io/apiserver/pkg/storage/storagebackend"
8
11
"sigs.k8s.io/apiserver-runtime/pkg/builder/resource"
9
12
builderrest "sigs.k8s.io/apiserver-runtime/pkg/builder/rest"
10
13
)
@@ -36,11 +39,17 @@ import (
36
39
func NewJSONFilepathStorageProvider (obj resource.Object , rootPath string ) builderrest.ResourceHandlerProvider {
37
40
return func (scheme * runtime.Scheme , getter generic.RESTOptionsGetter ) (rest.Storage , error ) {
38
41
gr := obj .GetGroupVersionResource ().GroupResource ()
39
- opt , err := getter .GetRESTOptions (gr )
42
+ codec , _ , err := storage .NewStorageCodec (storage.StorageCodecConfig {
43
+ StorageMediaType : runtime .ContentTypeJSON ,
44
+ StorageSerializer : serializer .NewCodecFactory (scheme ),
45
+ StorageVersion : scheme .PrioritizedVersionsForGroup (obj .GetGroupVersionResource ().Group )[0 ],
46
+ MemoryVersion : scheme .PrioritizedVersionsForGroup (obj .GetGroupVersionResource ().Group )[0 ],
47
+ Config : storagebackend.Config {}, // useless fields..
48
+ })
40
49
if err != nil {
41
50
return nil , err
42
51
}
43
- codec := opt . StorageConfig . Codec
52
+
44
53
return NewFilepathREST (
45
54
gr ,
46
55
codec ,
0 commit comments