forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrapper.go
63 lines (50 loc) · 2.29 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
package registry
import (
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest"
"github.com/openshift/origin/pkg/util/errors"
)
type NoWatchStorage interface {
rest.Getter
rest.Lister
rest.CreaterUpdater
rest.GracefulDeleter
}
// 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) Get(ctx request.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 request.Context, options *internalversion.ListOptions) (runtime.Object, error) {
obj, err := s.delegate.List(ctx, options)
return obj, errors.SyncStatusError(ctx, err)
}
func (s *noWatchStorageErrWrapper) Create(ctx request.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 request.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 request.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()
}