Browse Source

*: s/prevExists/prevExist/

Brian Waldon 11 years ago
parent
commit
91003cb994

+ 16 - 16
etcdserver/etcdhttp/http.go

@@ -207,35 +207,35 @@ func parseRequest(r *http.Request, id int64) (etcdserverpb.Request, error) {
 		)
 		)
 	}
 	}
 
 
-	// prevExists is nullable, so leave it null if not specified
+	// prevExist is nullable, so leave it null if not specified
 	var pe *bool
 	var pe *bool
-	if _, ok := r.Form["prevExists"]; ok {
-		bv, err := getBool(r.Form, "prevExists")
+	if _, ok := r.Form["prevExist"]; ok {
+		bv, err := getBool(r.Form, "prevExist")
 		if err != nil {
 		if err != nil {
 			return emptyReq, etcdErr.NewRequestError(
 			return emptyReq, etcdErr.NewRequestError(
 				etcdErr.EcodeInvalidField,
 				etcdErr.EcodeInvalidField,
-				"invalid value for prevExists",
+				"invalid value for prevExist",
 			)
 			)
 		}
 		}
 		pe = &bv
 		pe = &bv
 	}
 	}
 
 
 	rr := etcdserverpb.Request{
 	rr := etcdserverpb.Request{
-		Id:         id,
-		Method:     r.Method,
-		Path:       p,
-		Val:        r.FormValue("value"),
-		PrevValue:  r.FormValue("prevValue"),
-		PrevIndex:  pIdx,
-		PrevExists: pe,
-		Recursive:  rec,
-		Since:      wIdx,
-		Sorted:     sort,
-		Wait:       wait,
+		Id:        id,
+		Method:    r.Method,
+		Path:      p,
+		Val:       r.FormValue("value"),
+		PrevValue: r.FormValue("prevValue"),
+		PrevIndex: pIdx,
+		PrevExist: pe,
+		Recursive: rec,
+		Since:     wIdx,
+		Sorted:    sort,
+		Wait:      wait,
 	}
 	}
 
 
 	if pe != nil {
 	if pe != nil {
-		rr.PrevExists = pe
+		rr.PrevExist = pe
 	}
 	}
 
 
 	// TODO(jonboulle): use fake clock instead of time module
 	// TODO(jonboulle): use fake clock instead of time module

+ 27 - 27
etcdserver/etcdhttp/http_test.go

@@ -99,7 +99,7 @@ func TestBadParseRequest(t *testing.T) {
 			mustNewForm(t, "foo", url.Values{"ttl": []string{"-1"}}),
 			mustNewForm(t, "foo", url.Values{"ttl": []string{"-1"}}),
 			etcdErr.EcodeTTLNaN,
 			etcdErr.EcodeTTLNaN,
 		},
 		},
-		// bad values for recursive, sorted, wait, prevExists
+		// bad values for recursive, sorted, wait, prevExist
 		{
 		{
 			mustNewForm(t, "foo", url.Values{"recursive": []string{"hahaha"}}),
 			mustNewForm(t, "foo", url.Values{"recursive": []string{"hahaha"}}),
 			etcdErr.EcodeInvalidField,
 			etcdErr.EcodeInvalidField,
@@ -129,16 +129,16 @@ func TestBadParseRequest(t *testing.T) {
 			etcdErr.EcodeInvalidField,
 			etcdErr.EcodeInvalidField,
 		},
 		},
 		{
 		{
-			mustNewForm(t, "foo", url.Values{"prevExists": []string{"yes"}}),
+			mustNewForm(t, "foo", url.Values{"prevExist": []string{"yes"}}),
 			etcdErr.EcodeInvalidField,
 			etcdErr.EcodeInvalidField,
 		},
 		},
 		{
 		{
-			mustNewForm(t, "foo", url.Values{"prevExists": []string{"#2"}}),
+			mustNewForm(t, "foo", url.Values{"prevExist": []string{"#2"}}),
 			etcdErr.EcodeInvalidField,
 			etcdErr.EcodeInvalidField,
 		},
 		},
 		// query values are considered
 		// query values are considered
 		{
 		{
-			mustNewRequest(t, "foo?prevExists=wrong"),
+			mustNewRequest(t, "foo?prevExist=wrong"),
 			etcdErr.EcodeInvalidField,
 			etcdErr.EcodeInvalidField,
 		},
 		},
 		{
 		{
@@ -157,8 +157,8 @@ func TestBadParseRequest(t *testing.T) {
 		{
 		{
 			mustNewForm(
 			mustNewForm(
 				t,
 				t,
-				"foo?prevExists=false",
-				url.Values{"prevExists": []string{"yes"}},
+				"foo?prevExist=false",
+				url.Values{"prevExist": []string{"yes"}},
 			),
 			),
 			etcdErr.EcodeInvalidField,
 			etcdErr.EcodeInvalidField,
 		},
 		},
@@ -269,31 +269,31 @@ func TestGoodParseRequest(t *testing.T) {
 			},
 			},
 		},
 		},
 		{
 		{
-			// prevExists should be non-null if specified
+			// prevExist should be non-null if specified
 			mustNewForm(
 			mustNewForm(
 				t,
 				t,
 				"foo",
 				"foo",
-				url.Values{"prevExists": []string{"true"}},
+				url.Values{"prevExist": []string{"true"}},
 			),
 			),
 			etcdserverpb.Request{
 			etcdserverpb.Request{
-				Id:         1234,
-				Method:     "PUT",
-				PrevExists: boolp(true),
-				Path:       "/foo",
+				Id:        1234,
+				Method:    "PUT",
+				PrevExist: boolp(true),
+				Path:      "/foo",
 			},
 			},
 		},
 		},
 		{
 		{
-			// prevExists should be non-null if specified
+			// prevExist should be non-null if specified
 			mustNewForm(
 			mustNewForm(
 				t,
 				t,
 				"foo",
 				"foo",
-				url.Values{"prevExists": []string{"false"}},
+				url.Values{"prevExist": []string{"false"}},
 			),
 			),
 			etcdserverpb.Request{
 			etcdserverpb.Request{
-				Id:         1234,
-				Method:     "PUT",
-				PrevExists: boolp(false),
-				Path:       "/foo",
+				Id:        1234,
+				Method:    "PUT",
+				PrevExist: boolp(false),
+				Path:      "/foo",
 			},
 			},
 		},
 		},
 		// mix various fields
 		// mix various fields
@@ -302,18 +302,18 @@ func TestGoodParseRequest(t *testing.T) {
 				t,
 				t,
 				"foo",
 				"foo",
 				url.Values{
 				url.Values{
-					"value":      []string{"some value"},
-					"prevExists": []string{"true"},
-					"prevValue":  []string{"previous value"},
+					"value":     []string{"some value"},
+					"prevExist": []string{"true"},
+					"prevValue": []string{"previous value"},
 				},
 				},
 			),
 			),
 			etcdserverpb.Request{
 			etcdserverpb.Request{
-				Id:         1234,
-				Method:     "PUT",
-				PrevExists: boolp(true),
-				PrevValue:  "previous value",
-				Val:        "some value",
-				Path:       "/foo",
+				Id:        1234,
+				Method:    "PUT",
+				PrevExist: boolp(true),
+				PrevValue: "previous value",
+				Val:       "some value",
+				Path:      "/foo",
 			},
 			},
 		},
 		},
 		// query parameters should be used if given
 		// query parameters should be used if given

+ 5 - 5
etcdserver/etcdserverpb/etcdserver.pb.go

@@ -35,7 +35,7 @@ type Request struct {
 	Dir              bool   `protobuf:"varint,5,req,name=dir" json:"dir"`
 	Dir              bool   `protobuf:"varint,5,req,name=dir" json:"dir"`
 	PrevValue        string `protobuf:"bytes,6,req,name=prevValue" json:"prevValue"`
 	PrevValue        string `protobuf:"bytes,6,req,name=prevValue" json:"prevValue"`
 	PrevIndex        uint64 `protobuf:"varint,7,req,name=prevIndex" json:"prevIndex"`
 	PrevIndex        uint64 `protobuf:"varint,7,req,name=prevIndex" json:"prevIndex"`
-	PrevExists       *bool  `protobuf:"varint,8,req,name=prevExists" json:"prevExists,omitempty"`
+	PrevExist        *bool  `protobuf:"varint,8,req,name=prevExist" json:"prevExist,omitempty"`
 	Expiration       int64  `protobuf:"varint,9,req,name=expiration" json:"expiration"`
 	Expiration       int64  `protobuf:"varint,9,req,name=expiration" json:"expiration"`
 	Wait             bool   `protobuf:"varint,10,req,name=wait" json:"wait"`
 	Wait             bool   `protobuf:"varint,10,req,name=wait" json:"wait"`
 	Since            uint64 `protobuf:"varint,11,req,name=since" json:"since"`
 	Since            uint64 `protobuf:"varint,11,req,name=since" json:"since"`
@@ -223,7 +223,7 @@ func (m *Request) Unmarshal(data []byte) error {
 				}
 				}
 			}
 			}
 			b := bool(v != 0)
 			b := bool(v != 0)
-			m.PrevExists = &b
+			m.PrevExist = &b
 		case 9:
 		case 9:
 			if wireType != 0 {
 			if wireType != 0 {
 				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
 				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
@@ -374,7 +374,7 @@ func (m *Request) Size() (n int) {
 	l = len(m.PrevValue)
 	l = len(m.PrevValue)
 	n += 1 + l + sovEtcdserver(uint64(l))
 	n += 1 + l + sovEtcdserver(uint64(l))
 	n += 1 + sovEtcdserver(uint64(m.PrevIndex))
 	n += 1 + sovEtcdserver(uint64(m.PrevIndex))
-	if m.PrevExists != nil {
+	if m.PrevExist != nil {
 		n += 2
 		n += 2
 	}
 	}
 	n += 1 + sovEtcdserver(uint64(m.Expiration))
 	n += 1 + sovEtcdserver(uint64(m.Expiration))
@@ -448,10 +448,10 @@ func (m *Request) MarshalTo(data []byte) (n int, err error) {
 	data[i] = 0x38
 	data[i] = 0x38
 	i++
 	i++
 	i = encodeVarintEtcdserver(data, i, uint64(m.PrevIndex))
 	i = encodeVarintEtcdserver(data, i, uint64(m.PrevIndex))
-	if m.PrevExists != nil {
+	if m.PrevExist != nil {
 		data[i] = 0x40
 		data[i] = 0x40
 		i++
 		i++
-		if *m.PrevExists {
+		if *m.PrevExist {
 			data[i] = 1
 			data[i] = 1
 		} else {
 		} else {
 			data[i] = 0
 			data[i] = 0

+ 1 - 1
etcdserver/etcdserverpb/etcdserver.proto

@@ -15,7 +15,7 @@ message Request {
 	required bool   dir        =  5 [(gogoproto.nullable) = false];
 	required bool   dir        =  5 [(gogoproto.nullable) = false];
 	required string prevValue  =  6 [(gogoproto.nullable) = false];
 	required string prevValue  =  6 [(gogoproto.nullable) = false];
 	required uint64  prevIndex =  7 [(gogoproto.nullable) = false];
 	required uint64  prevIndex =  7 [(gogoproto.nullable) = false];
-	required bool   prevExists =  8 [(gogoproto.nullable) = true];
+	required bool   prevExist  =  8 [(gogoproto.nullable) = true];
 	required int64  expiration =  9 [(gogoproto.nullable) = false];
 	required int64  expiration =  9 [(gogoproto.nullable) = false];
 	required bool   wait       = 10 [(gogoproto.nullable) = false];
 	required bool   wait       = 10 [(gogoproto.nullable) = false];
 	required uint64  since     = 11 [(gogoproto.nullable) = false];
 	required uint64  since     = 11 [(gogoproto.nullable) = false];

+ 1 - 1
etcdserver/server.go

@@ -251,7 +251,7 @@ func (s *EtcdServer) apply(r pb.Request) Response {
 	case "POST":
 	case "POST":
 		return f(s.Store.Create(r.Path, r.Dir, r.Val, true, expr))
 		return f(s.Store.Create(r.Path, r.Dir, r.Val, true, expr))
 	case "PUT":
 	case "PUT":
-		exists, existsSet := getBool(r.PrevExists)
+		exists, existsSet := getBool(r.PrevExist)
 		switch {
 		switch {
 		case existsSet:
 		case existsSet:
 			if exists {
 			if exists {

+ 4 - 4
etcdserver/server_test.go

@@ -69,19 +69,19 @@ func TestApply(t *testing.T) {
 			Response{Event: &store.Event{}}, []string{"Create"},
 			Response{Event: &store.Event{}}, []string{"Create"},
 		},
 		},
 		{
 		{
-			pb.Request{Method: "PUT", Id: 1, PrevExists: boolp(true), PrevIndex: 1},
+			pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(true), PrevIndex: 1},
 			Response{Event: &store.Event{}}, []string{"Update"},
 			Response{Event: &store.Event{}}, []string{"Update"},
 		},
 		},
 		{
 		{
-			pb.Request{Method: "PUT", Id: 1, PrevExists: boolp(false), PrevIndex: 1},
+			pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(false), PrevIndex: 1},
 			Response{Event: &store.Event{}}, []string{"Create"},
 			Response{Event: &store.Event{}}, []string{"Create"},
 		},
 		},
 		{
 		{
-			pb.Request{Method: "PUT", Id: 1, PrevExists: boolp(true)},
+			pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(true)},
 			Response{Event: &store.Event{}}, []string{"Update"},
 			Response{Event: &store.Event{}}, []string{"Update"},
 		},
 		},
 		{
 		{
-			pb.Request{Method: "PUT", Id: 1, PrevExists: boolp(false)},
+			pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(false)},
 			Response{Event: &store.Event{}}, []string{"Create"},
 			Response{Event: &store.Event{}}, []string{"Create"},
 		},
 		},
 		{
 		{