Add the resource version to api.*List items from etcd

Allows clients to watch more easily (can invoke Get, then
Watch).
This commit is contained in:
Clayton Coleman
2014-08-28 20:48:07 -04:00
parent c380dd0426
commit bafc422ac0
17 changed files with 120 additions and 89 deletions

View File

@@ -66,6 +66,7 @@ func TestExtractList(t *testing.T) {
fakeClient := NewFakeEtcdClient(t)
fakeClient.Data["/some/key"] = EtcdResponseWithError{
R: &etcd.Response{
EtcdIndex: 10,
Node: &etcd.Node{
Nodes: []*etcd.Node{
{
@@ -92,10 +93,14 @@ func TestExtractList(t *testing.T) {
var got []api.Pod
helper := EtcdHelper{fakeClient, codec, versioner}
err := helper.ExtractList("/some/key", &got)
resourceVersion := uint64(0)
err := helper.ExtractList("/some/key", &got, &resourceVersion)
if err != nil {
t.Errorf("Unexpected error %#v", err)
}
if resourceVersion != 10 {
t.Errorf("Unexpected resource version %d", resourceVersion)
}
for i := 0; i < len(expect); i++ {
if !reflect.DeepEqual(got[i], expect[i]) {