以下示例是关于golang中包含rest.Storage用法的示例代码,想了解rest.Storage的具体用法?rest.Storage怎么用?rest.Storage使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。
43 *testing.T
44 storage rest.Storage
45 clusterScope bool
52
53func New(t *testing.T, storage rest.Storage, scheme *runtime.Scheme) *Tester {
54 return &Tester{
43 *testing.T
44 storage rest.Storage
45 clusterScope bool
52
53func New(t *testing.T, storage rest.Storage, scheme *runtime.Scheme) *Tester {
54 return &Tester{
256// uses the default settings
257func handle(storage map[string]rest.Storage) http.Handler {
258 return handleInternal(storage, admissionControl, selfLinker, nil)
261// tests with a deny admission controller
262func handleDeny(storage map[string]rest.Storage) http.Handler {
263 return handleInternal(storage, alwaysDeny{}, selfLinker, nil)
266// tests using the new namespace scope mechanism
267func handleNamespaced(storage map[string]rest.Storage) http.Handler {
268 return handleInternal(storage, admissionControl, selfLinker, nil)
271// tests using a custom self linker
272func handleLinker(storage map[string]rest.Storage, selfLinker runtime.SelfLinker) http.Handler {
273 return handleInternal(storage, admissionControl, selfLinker, nil)
275
276func handleInternal(storage map[string]rest.Storage, admissionControl admission.Interface, selfLinker runtime.SelfLinker, auditSink audit.Sink) http.Handler {
277 container := restful.NewContainer()
137// the group version kind supplied in the override.
138func (a *APIInstaller) getResourceKind(path string, storage rest.Storage) (schema.GroupVersionKind, error) {
139 if fqKindToRegister, ok := a.group.SubresourceGroupVersionKind[path]; ok {
192
193func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storage, ws *restful.WebService, proxyHandler http.Handler) (*metav1.APIResource, error) {
194 admit := a.group.Admit
241 connecter, isConnecter := storage.(rest.Connecter)
242 storageMeta, isMetadata := storage.(rest.StorageMetadata)
243 if !isMetadata {
962
963// defaultStorageMetadata provides default answers to rest.StorageMetadata.
964type defaultStorageMetadata struct{}
965
966// defaultStorageMetadata implements rest.StorageMetadata
967var _ rest.StorageMetadata = defaultStorageMetadata{}
265// uses the default settings
266func handle(storage map[string]rest.Storage) http.Handler {
267 return handleInternal(storage, admissionControl, selfLinker, nil)
270// tests with a deny admission controller
271func handleDeny(storage map[string]rest.Storage) http.Handler {
272 return handleInternal(storage, alwaysDeny{}, selfLinker, nil)
275// tests using the new namespace scope mechanism
276func handleNamespaced(storage map[string]rest.Storage) http.Handler {
277 return handleInternal(storage, admissionControl, selfLinker, nil)
280// tests using a custom self linker
281func handleLinker(storage map[string]rest.Storage, selfLinker runtime.SelfLinker) http.Handler {
282 return handleInternal(storage, admissionControl, selfLinker, nil)
284
285func handleInternal(storage map[string]rest.Storage, admissionControl admission.Interface, selfLinker runtime.SelfLinker, auditSink audit.Sink) http.Handler {
286 container := restful.NewContainer()
137// the group version kind supplied in the override.
138func (a *APIInstaller) getResourceKind(path string, storage rest.Storage) (schema.GroupVersionKind, error) {
139 if fqKindToRegister, ok := a.group.SubresourceGroupVersionKind[path]; ok {
192
193func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storage, ws *restful.WebService, proxyHandler http.Handler) (*metav1.APIResource, error) {
194 admit := a.group.Admit
241 connecter, isConnecter := storage.(rest.Connecter)
242 storageMeta, isMetadata := storage.(rest.StorageMetadata)
243 if !isMetadata {
962
963// defaultStorageMetadata provides default answers to rest.StorageMetadata.
964type defaultStorageMetadata struct{}
965
966// defaultStorageMetadata implements rest.StorageMetadata
967var _ rest.StorageMetadata = defaultStorageMetadata{}
43 *testing.T
44 storage rest.Storage
45 clusterScope bool
51
52func New(t *testing.T, storage rest.Storage) *Tester {
53 return &Tester{
39 *testing.T
40 storage rest.Storage
41 clusterScope bool
46
47func New(t *testing.T, storage rest.Storage) *Tester {
48 return &Tester{
266// uses the default settings
267func handle(storage map[string]rest.Storage) http.Handler {
268 return handleInternal(storage, admissionControl, selfLinker, nil)
271// tests using the new namespace scope mechanism
272func handleNamespaced(storage map[string]rest.Storage) http.Handler {
273 return handleInternal(storage, admissionControl, selfLinker, nil)
276// tests using a custom self linker
277func handleLinker(storage map[string]rest.Storage, selfLinker runtime.SelfLinker) http.Handler {
278 return handleInternal(storage, admissionControl, selfLinker, nil)
280
281func handleInternal(storage map[string]rest.Storage, admissionControl admission.Interface, selfLinker runtime.SelfLinker, auditSink audit.Sink) http.Handler {
282 container := restful.NewContainer()
678
679var _ rest.StorageMetadata = &MetadataRESTStorage{}
680
145// the group version kind supplied in the override.
146func (a *APIInstaller) getResourceKind(path string, storage rest.Storage) (schema.GroupVersionKind, error) {
147 // Let the storage tell us exactly what GVK it has
195
196func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storage, ws *restful.WebService, proxyHandler http.Handler) (*metav1.APIResource, error) {
197 admit := a.group.Admit
244 connecter, isConnecter := storage.(rest.Connecter)
245 storageMeta, isMetadata := storage.(rest.StorageMetadata)
246 if !isMetadata {
1008
1009// defaultStorageMetadata provides default answers to rest.StorageMetadata.
1010type defaultStorageMetadata struct{}
1011
1012// defaultStorageMetadata implements rest.StorageMetadata
1013var _ rest.StorageMetadata = defaultStorageMetadata{}
本文地址:https://www.itbaoku.cn/snippets/415772.html