Update generic etcd to enable namespace scoped resources
This commit is contained in:
@@ -35,7 +35,11 @@ type registry struct {
|
||||
|
||||
// Create stores the object with a ttl, so that events don't stay in the system forever.
|
||||
func (r registry) Create(ctx api.Context, id string, obj runtime.Object) error {
|
||||
err := r.Etcd.Helper.CreateObj(r.Etcd.KeyFunc(id), obj, r.ttl)
|
||||
key, err := r.Etcd.KeyFunc(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = r.Etcd.Helper.CreateObj(key, obj, r.ttl)
|
||||
return etcderr.InterpretCreateError(err, r.Etcd.EndpointName, id)
|
||||
}
|
||||
|
||||
@@ -47,9 +51,12 @@ func NewEtcdRegistry(h tools.EtcdHelper, ttl uint64) generic.Registry {
|
||||
NewFunc: func() runtime.Object { return &api.Event{} },
|
||||
NewListFunc: func() runtime.Object { return &api.EventList{} },
|
||||
EndpointName: "events",
|
||||
KeyRoot: "/registry/events",
|
||||
KeyFunc: func(id string) string {
|
||||
return path.Join("/registry/events", id)
|
||||
KeyRoot: func(ctx api.Context) string {
|
||||
return "/registry/events"
|
||||
},
|
||||
KeyFunc: func(ctx api.Context, id string) (string, error) {
|
||||
// TODO - we need to store this in a namespace relative path
|
||||
return path.Join("/registry/events", id), nil
|
||||
},
|
||||
Helper: h,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user