Embed generic etcd in namespace rest store

pull/6/head
derekwaynecarr 2015-03-16 10:45:04 -04:00
parent 2d13dfaf13
commit 9824d2b5f7
2 changed files with 3 additions and 44 deletions

View File

@ -25,12 +25,11 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/namespace" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/namespace"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
) )
// rest implements a RESTStorage for namespaces against etcd // rest implements a RESTStorage for namespaces against etcd
type REST struct { type REST struct {
store *etcdgeneric.Etcd *etcdgeneric.Etcd
} }
// NewREST returns a RESTStorage object that will work against namespaces // NewREST returns a RESTStorage object that will work against namespaces
@ -57,45 +56,5 @@ func NewREST(h tools.EtcdHelper) *REST {
store.UpdateStrategy = namespace.Strategy store.UpdateStrategy = namespace.Strategy
store.ReturnDeletedObject = true store.ReturnDeletedObject = true
return &REST{store: store} return &REST{Etcd: store}
}
// New returns a new object
func (r *REST) New() runtime.Object {
return r.store.NewFunc()
}
// NewList returns a new list object
func (r *REST) NewList() runtime.Object {
return r.store.NewListFunc()
}
// List obtains a list of namespaces with labels that match selector.
func (r *REST) List(ctx api.Context, label labels.Selector, field fields.Selector) (runtime.Object, error) {
return r.store.List(ctx, label, field)
}
// Watch begins watching for new, changed, or deleted namespaces
func (r *REST) Watch(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return r.store.Watch(ctx, label, field, resourceVersion)
}
// Get gets a specific namespace specified by its name
func (r *REST) Get(ctx api.Context, name string) (runtime.Object, error) {
return r.store.Get(ctx, name)
}
// Create creates a namespace based on a specification.
func (r *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, error) {
return r.store.Create(ctx, obj)
}
// Update changes a namespace specification.
func (r *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, bool, error) {
return r.store.Update(ctx, obj)
}
// Delete deletes an existing namespace specified by its name
func (r *REST) Delete(ctx api.Context, name string) (runtime.Object, error) {
return r.store.Delete(ctx, name)
} }

View File

@ -38,7 +38,7 @@ type namespaceStrategy struct {
// objects via the REST API. // objects via the REST API.
var Strategy = namespaceStrategy{api.Scheme, api.SimpleNameGenerator} var Strategy = namespaceStrategy{api.Scheme, api.SimpleNameGenerator}
// NamespaceScoped is true for namespaces. // NamespaceScoped is false for namespaces.
func (namespaceStrategy) NamespaceScoped() bool { func (namespaceStrategy) NamespaceScoped() bool {
return false return false
} }