Browse Source

etcdserver/member: change JSON fields to lowerCamelCase

Jonathan Boulle 11 years ago
parent
commit
543e12074a

+ 9 - 9
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"
             ],
         },

+ 9 - 9
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)

+ 1 - 1
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},
 		},

+ 4 - 4
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
 }