From 440ce7cb39f62c4f5e96a8ebf6562d1ca37db11b Mon Sep 17 00:00:00 2001 From: Kent Dong Date: Wed, 31 Jan 2024 09:55:32 +0800 Subject: [PATCH] feat: Define a unified storage interface for storage backend integration (#55) --- src/apiserver/pkg/registry/file_rest.go | 2 +- src/apiserver/pkg/registry/nacos_rest.go | 2 +- src/apiserver/pkg/registry/registry.go | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/apiserver/pkg/registry/file_rest.go b/src/apiserver/pkg/registry/file_rest.go index 8faafc1..0fe72dc 100644 --- a/src/apiserver/pkg/registry/file_rest.go +++ b/src/apiserver/pkg/registry/file_rest.go @@ -53,7 +53,7 @@ func NewFileREST( newFunc func() runtime.Object, newListFunc func() runtime.Object, attrFunc storage.AttrFunc, -) (rest.Storage, error) { +) (REST, error) { if attrFunc == nil { if isNamespaced { if isNamespaced { diff --git a/src/apiserver/pkg/registry/nacos_rest.go b/src/apiserver/pkg/registry/nacos_rest.go index 2210ee3..79a46c8 100644 --- a/src/apiserver/pkg/registry/nacos_rest.go +++ b/src/apiserver/pkg/registry/nacos_rest.go @@ -62,7 +62,7 @@ func NewNacosREST( newListFunc func() runtime.Object, attrFunc storage.AttrFunc, dataEncryptionKey []byte, -) rest.Storage { +) REST { if attrFunc == nil { if isNamespaced { if isNamespaced { diff --git a/src/apiserver/pkg/registry/registry.go b/src/apiserver/pkg/registry/registry.go index bb30995..74a2ac9 100644 --- a/src/apiserver/pkg/registry/registry.go +++ b/src/apiserver/pkg/registry/registry.go @@ -21,9 +21,13 @@ import ( "k8s.io/apiserver/pkg/registry/rest" ) -// REST implements a RESTStorage for API services against etcd -type REST struct { +// REST defines a storage interface for integrating different storage backends with api server. +type REST interface { rest.Storage + rest.StandardStorage + rest.SingularNameProvider + rest.Scoper + rest.TableConvertor } // RESTInPeace is just a simple function that panics on error.