Enforce unique constraint at namespace boundary in etcd, make client and server namespace aware
This commit is contained in:
@@ -179,18 +179,18 @@ func (h *EtcdHelper) decodeNodeList(nodes []*etcd.Node, slicePtr interface{}) er
|
||||
for _, node := range nodes {
|
||||
if node.Dir {
|
||||
h.decodeNodeList(node.Nodes, slicePtr)
|
||||
} else {
|
||||
obj := reflect.New(v.Type().Elem())
|
||||
err := h.Codec.DecodeInto([]byte(node.Value), obj.Interface().(runtime.Object))
|
||||
if h.ResourceVersioner != nil {
|
||||
_ = h.ResourceVersioner.SetResourceVersion(obj.Interface().(runtime.Object), node.ModifiedIndex)
|
||||
// being unable to set the version does not prevent the object from being extracted
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.Append(v, obj.Elem()))
|
||||
continue
|
||||
}
|
||||
obj := reflect.New(v.Type().Elem())
|
||||
err := h.Codec.DecodeInto([]byte(node.Value), obj.Interface().(runtime.Object))
|
||||
if h.ResourceVersioner != nil {
|
||||
_ = h.ResourceVersioner.SetResourceVersion(obj.Interface().(runtime.Object), node.ModifiedIndex)
|
||||
// being unable to set the version does not prevent the object from being extracted
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.Append(v, obj.Elem()))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -141,10 +141,10 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
|
||||
},
|
||||
}
|
||||
expect := api.PodList{
|
||||
JSONBase: api.JSONBase{ResourceVersion: 10},
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "10"},
|
||||
Items: []api.Pod{
|
||||
{JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1}},
|
||||
{JSONBase: api.JSONBase{ID: "bar", ResourceVersion: 2}},
|
||||
{TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}},
|
||||
{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "2"}},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -187,11 +187,11 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
|
||||
},
|
||||
}
|
||||
expect := api.PodList{
|
||||
JSONBase: api.JSONBase{ResourceVersion: 10},
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "10"},
|
||||
Items: []api.Pod{
|
||||
{JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1}},
|
||||
{JSONBase: api.JSONBase{ID: "bar", ResourceVersion: 2}},
|
||||
{JSONBase: api.JSONBase{ID: "baz", ResourceVersion: 3}},
|
||||
{TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"}},
|
||||
{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: "2"}},
|
||||
{TypeMeta: api.TypeMeta{ID: "baz", ResourceVersion: "3"}},
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user