From 543e12074ae0e315ee034fef744e3817726b3bd5 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Fri, 24 Oct 2014 10:57:56 -0700 Subject: [PATCH] etcdserver/member: change JSON fields to lowerCamelCase --- Documentation/0.5/admin_api.md | 18 +++++++++--------- etcdserver/cluster_test.go | 18 +++++++++--------- etcdserver/etcdhttp/http_test.go | 2 +- etcdserver/member.go | 8 ++++---- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Documentation/0.5/admin_api.md b/Documentation/0.5/admin_api.md index 0ec26658d..f8e4b582b 100644 --- a/Documentation/0.5/admin_api.md +++ b/Documentation/0.5/admin_api.md @@ -12,22 +12,22 @@ Return an HTTP 200 OK response code and a representation of all members in the e { "members": [ { - "ID":"272e204152", - "Name":"node1", - "PeerURLs":[ + "id":"272e204152", + "name":"node1", + "peerURLs":[ "http://10.0.0.10:2379" ], - "ClientURLs":[ + "clientURLs":[ "http://10.0.0.10:2380" ] }, { - "ID":"2225373f43", - "Name":"node2", - "PeerURLs":[ + "id":"2225373f43", + "name":"node2", + "peerURLs":[ "http://127.0.0.11:2379" ], - "ClientURLs":[ + "clientURLs":[ "http://127.0.0.11:2380" ] }, @@ -52,7 +52,7 @@ If the POST body is malformed an HTTP 400 will be returned. If the member exists [ { "id":"3777296169", - "PeerURLs":[ + "peerURLs":[ "http://10.0.0.10:2379" ], }, diff --git a/etcdserver/cluster_test.go b/etcdserver/cluster_test.go index 2eeace978..e29a671ba 100644 --- a/etcdserver/cluster_test.go +++ b/etcdserver/cluster_test.go @@ -311,19 +311,19 @@ func TestNodeToMemberBad(t *testing.T) { {Key: "/1234/dynamic", Value: stringp("garbage")}, }}, {Key: "/1234", Nodes: []*store.NodeExtern{ - {Key: "/1234/dynamic", Value: stringp(`{"PeerURLs":null}`)}, + {Key: "/1234/dynamic", Value: stringp(`{"peerURLs":null}`)}, }}, {Key: "/1234", Nodes: []*store.NodeExtern{ - {Key: "/1234/dynamic", Value: stringp(`{"PeerURLs":null}`)}, + {Key: "/1234/dynamic", Value: stringp(`{"peerURLs":null}`)}, {Key: "/1234/strange"}, }}, {Key: "/1234", Nodes: []*store.NodeExtern{ - {Key: "/1234/dynamic", Value: stringp(`{"PeerURLs":null}`)}, + {Key: "/1234/dynamic", Value: stringp(`{"peerURLs":null}`)}, {Key: "/1234/static", Value: stringp("garbage")}, }}, {Key: "/1234", Nodes: []*store.NodeExtern{ - {Key: "/1234/dynamic", Value: stringp(`{"PeerURLs":null}`)}, - {Key: "/1234/static", Value: stringp(`{"Name":"node1","ClientURLs":null}`)}, + {Key: "/1234/dynamic", Value: stringp(`{"peerURLs":null}`)}, + {Key: "/1234/static", Value: stringp(`{"name":"node1","clientURLs":null}`)}, {Key: "/1234/strange"}, }}, } @@ -346,7 +346,7 @@ func TestClusterAddMember(t *testing.T) { params: []interface{}{ path.Join(storeMembersPrefix, "1", "raftAttributes"), false, - `{"PeerURLs":null}`, + `{"peerURLs":null}`, false, store.Permanent, }, @@ -356,7 +356,7 @@ func TestClusterAddMember(t *testing.T) { params: []interface{}{ path.Join(storeMembersPrefix, "1", "attributes"), false, - `{"Name":"node1"}`, + `{"name":"node1"}`, false, store.Permanent, }, @@ -449,8 +449,8 @@ func TestClusterRemoveMember(t *testing.T) { func TestNodeToMember(t *testing.T) { n := &store.NodeExtern{Key: "/1234", Nodes: []*store.NodeExtern{ - {Key: "/1234/attributes", Value: stringp(`{"Name":"node1","ClientURLs":null}`)}, - {Key: "/1234/raftAttributes", Value: stringp(`{"PeerURLs":null}`)}, + {Key: "/1234/attributes", Value: stringp(`{"name":"node1","clientURLs":null}`)}, + {Key: "/1234/raftAttributes", Value: stringp(`{"peerURLs":null}`)}, }} wm := &Member{ID: 0x1234, RaftAttributes: RaftAttributes{}, Attributes: Attributes{Name: "node1"}} m, err := nodeToMember(n) diff --git a/etcdserver/etcdhttp/http_test.go b/etcdserver/etcdhttp/http_test.go index 6150c81bd..cbebc12a0 100644 --- a/etcdserver/etcdhttp/http_test.go +++ b/etcdserver/etcdhttp/http_test.go @@ -1619,7 +1619,7 @@ func TestServeAdminMembers(t *testing.T) { msb, err := json.Marshal( struct { - Members []etcdserver.Member + Members []etcdserver.Member `json:"members"` }{ Members: []etcdserver.Member{memb1, memb2}, }, diff --git a/etcdserver/member.go b/etcdserver/member.go index 51e03a65e..d4ec14f4b 100644 --- a/etcdserver/member.go +++ b/etcdserver/member.go @@ -33,17 +33,17 @@ import ( // RaftAttributes represents the raft related attributes of an etcd member. type RaftAttributes struct { // TODO(philips): ensure these are URLs - PeerURLs []string + PeerURLs []string `json:"peerURLs"` } // Attributes represents all the non-raft related attributes of an etcd member. type Attributes struct { - Name string `json:",omitempty"` - ClientURLs []string `json:",omitempty"` + Name string `json:"name,omitempty"` + ClientURLs []string `json:"clientURLs,omitempty"` } type Member struct { - ID uint64 + ID uint64 `json:"id"` RaftAttributes Attributes }