forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wrapper.go
75 lines (59 loc) · 2.66 KB
/
wrapper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package registry
import (
"context"
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
"github.com/openshift/origin/pkg/util/errors"
)
type NoWatchStorage interface {
rest.Getter
rest.Lister
rest.TableConvertor
rest.CreaterUpdater
rest.GracefulDeleter
rest.Scoper
}
// WrapNoWatchStorageError uses SyncStatusError to inject the correct group
// resource info into the errors that are returned by the delegated storage
func WrapNoWatchStorageError(delegate NoWatchStorage) NoWatchStorage {
return &noWatchStorageErrWrapper{delegate: delegate}
}
var _ = NoWatchStorage(&noWatchStorageErrWrapper{})
type noWatchStorageErrWrapper struct {
delegate NoWatchStorage
}
func (s *noWatchStorageErrWrapper) NamespaceScoped() bool {
return s.delegate.NamespaceScoped()
}
func (s *noWatchStorageErrWrapper) Get(ctx context.Context, name string, options *v1.GetOptions) (runtime.Object, error) {
obj, err := s.delegate.Get(ctx, name, options)
return obj, errors.SyncStatusError(ctx, err)
}
func (s *noWatchStorageErrWrapper) List(ctx context.Context, options *internalversion.ListOptions) (runtime.Object, error) {
obj, err := s.delegate.List(ctx, options)
return obj, errors.SyncStatusError(ctx, err)
}
func (s *noWatchStorageErrWrapper) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
return s.delegate.ConvertToTable(ctx, object, tableOptions)
}
func (s *noWatchStorageErrWrapper) Create(ctx context.Context, in runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
obj, err := s.delegate.Create(ctx, in, createValidation, includeUninitialized)
return obj, errors.SyncStatusError(ctx, err)
}
func (s *noWatchStorageErrWrapper) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
obj, created, err := s.delegate.Update(ctx, name, objInfo, createValidation, updateValidation)
return obj, created, errors.SyncStatusError(ctx, err)
}
func (s *noWatchStorageErrWrapper) Delete(ctx context.Context, name string, options *v1.DeleteOptions) (runtime.Object, bool, error) {
obj, deleted, err := s.delegate.Delete(ctx, name, options)
return obj, deleted, errors.SyncStatusError(ctx, err)
}
func (s *noWatchStorageErrWrapper) New() runtime.Object {
return s.delegate.New()
}
func (s *noWatchStorageErrWrapper) NewList() runtime.Object {
return s.delegate.NewList()
}