forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
etcd.go
61 lines (48 loc) · 1.87 KB
/
etcd.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
package etcd
import (
"k8s.io/apimachinery/pkg/runtime"
apirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest"
kapi "k8s.io/kubernetes/pkg/api"
buildapi "github.com/openshift/origin/pkg/build/apis/build"
"github.com/openshift/origin/pkg/build/registry/build"
"github.com/openshift/origin/pkg/util/restoptions"
)
type REST struct {
*registry.Store
}
var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against Build objects.
func NewREST(optsGetter restoptions.Getter) (*REST, *DetailsREST, error) {
store := ®istry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &buildapi.Build{} },
NewListFunc: func() runtime.Object { return &buildapi.BuildList{} },
PredicateFunc: build.Matcher,
DefaultQualifiedResource: buildapi.Resource("builds"),
CreateStrategy: build.Strategy,
UpdateStrategy: build.Strategy,
DeleteStrategy: build.Strategy,
}
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: build.GetAttrs}
if err := store.CompleteWithOptions(options); err != nil {
return nil, nil, err
}
detailsStore := *store
detailsStore.UpdateStrategy = build.DetailsStrategy
return &REST{store}, &DetailsREST{&detailsStore}, nil
}
type DetailsREST struct {
store *registry.Store
}
var _ rest.Updater = &DetailsREST{}
// New returns an empty object that can be used with Update after request data has been put into it.
func (r *DetailsREST) New() runtime.Object {
return r.store.New()
}
// Update finds a resource in the storage and updates it.
func (r *DetailsREST) Update(ctx apirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo)
}