*: regenerate proto to use local import path

Using Go-style import paths in protos is not idiomatic. Normally, this
detail would be internal to etcd, but the path from which gogoproto
is imported affects downstream consumers (e.g. cockroachdb).

In cockroach, we want to avoid including `$GOPATH/src` in our protoc
include path for various reasons. This patch puts etcd on the same
convention, which allows this for cockroach.

More information: https://github.com/cockroachdb/cockroach/pull/2339#discussion_r38663417

This commit also regenerates all the protos, which seem to have
drifted a tiny bit.
This commit is contained in:
Tamir Duberstein 2015-09-03 12:57:59 -04:00
parent 1eaf169057
commit 45390b9fb8
15 changed files with 70 additions and 27 deletions

View File

@ -19,7 +19,7 @@ package etcdserverpb
import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto" import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
import math "math" import math "math"
// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" // discarding unused import gogoproto "github.com/coreos/etcd/Godeps/_workspace/src/gogoproto/gogo.pb"
import io "io" import io "io"
import fmt "fmt" import fmt "fmt"

View File

@ -1,7 +1,7 @@
syntax = "proto2"; syntax = "proto2";
package etcdserverpb; package etcdserverpb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true; option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true; option (gogoproto.sizer_all) = true;

View File

@ -6,7 +6,7 @@ package etcdserverpb
import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto" import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" // discarding unused import gogoproto "github.com/coreos/etcd/Godeps/_workspace/src/gogoproto/gogo.pb"
import io "io" import io "io"
import fmt "fmt" import fmt "fmt"

View File

@ -1,7 +1,7 @@
syntax = "proto3"; syntax = "proto3";
package etcdserverpb; package etcdserverpb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
import "etcdserver.proto"; import "etcdserver.proto";
import "rpc.proto"; import "rpc.proto";

View File

@ -6,7 +6,7 @@ package etcdserverpb
import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto" import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" // discarding unused import gogoproto "github.com/coreos/etcd/Godeps/_workspace/src/gogoproto/gogo.pb"
import storagepb "github.com/coreos/etcd/storage/storagepb" import storagepb "github.com/coreos/etcd/storage/storagepb"
import io "io" import io "io"
@ -108,6 +108,8 @@ type RangeResponse struct {
Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"` Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
Kvs []*storagepb.KeyValue `protobuf:"bytes,2,rep,name=kvs" json:"kvs,omitempty"` Kvs []*storagepb.KeyValue `protobuf:"bytes,2,rep,name=kvs" json:"kvs,omitempty"`
ConsistentToken []byte `protobuf:"bytes,3,opt,name=consistent_token,proto3" json:"consistent_token,omitempty"` ConsistentToken []byte `protobuf:"bytes,3,opt,name=consistent_token,proto3" json:"consistent_token,omitempty"`
// more indicates if there are more keys to return in the requested range.
More bool `protobuf:"varint,4,opt,name=more,proto3" json:"more,omitempty"`
} }
func (m *RangeResponse) Reset() { *m = RangeResponse{} } func (m *RangeResponse) Reset() { *m = RangeResponse{} }
@ -329,6 +331,10 @@ func (m *TxnResponse) GetResponses() []*ResponseUnion {
return nil return nil
} }
// Compaction compacts the kv store upto the given index (including).
// It removes the old versions of a key. It keeps the newest version of
// the key even if its latest modification index is smaller than the given
// index.
type CompactionRequest struct { type CompactionRequest struct {
Index int64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` Index int64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
} }
@ -696,6 +702,23 @@ func (m *RangeResponse) Unmarshal(data []byte) error {
} }
m.ConsistentToken = append([]byte{}, data[iNdEx:postIndex]...) m.ConsistentToken = append([]byte{}, data[iNdEx:postIndex]...)
iNdEx = postIndex iNdEx = postIndex
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field More", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
v |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
m.More = bool(v != 0)
default: default:
var sizeOfWire int var sizeOfWire int
for { for {
@ -1942,6 +1965,9 @@ func (m *RangeResponse) Size() (n int) {
n += 1 + l + sovRpc(uint64(l)) n += 1 + l + sovRpc(uint64(l))
} }
} }
if m.More {
n += 2
}
return n return n
} }
@ -2281,6 +2307,16 @@ func (m *RangeResponse) MarshalTo(data []byte) (n int, err error) {
i += copy(data[i:], m.ConsistentToken) i += copy(data[i:], m.ConsistentToken)
} }
} }
if m.More {
data[i] = 0x20
i++
if m.More {
data[i] = 1
} else {
data[i] = 0
}
i++
}
return i, nil return i, nil
} }

View File

@ -1,8 +1,8 @@
syntax = "proto3"; syntax = "proto3";
package etcdserverpb; package etcdserverpb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
import "github.com/coreos/etcd/storage/storagepb/kv.proto"; import "etcd/storage/storagepb/kv.proto";
option (gogoproto.marshaler_all) = true; option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true; option (gogoproto.unmarshaler_all) = true;
@ -50,7 +50,7 @@ message RangeRequest {
bytes range_end = 2; bytes range_end = 2;
// limit the number of keys returned. // limit the number of keys returned.
int64 limit = 3; int64 limit = 3;
// the response will be consistent with previous request with same token if the token is // the response will be consistent with previous request with same token if the token is
// given and is valid. // given and is valid.
bytes consistent_token = 4; bytes consistent_token = 4;
} }
@ -127,9 +127,9 @@ message Compare {
} }
} }
// If the comparisons succeed, then the success requests will be processed in order, // If the comparisons succeed, then the success requests will be processed in order,
// and the response will contain their respective responses in order. // and the response will contain their respective responses in order.
// If the comparisons fail, then the failure requests will be processed in order, // If the comparisons fail, then the failure requests will be processed in order,
// and the response will contain their respective responses in order. // and the response will contain their respective responses in order.
// From google paxosdb paper: // From google paxosdb paper:
@ -159,9 +159,9 @@ message TxnResponse {
repeated ResponseUnion responses = 3; repeated ResponseUnion responses = 3;
} }
// Compaction compacts the kv store upto the given index (including). // Compaction compacts the kv store upto the given index (including).
// It removes the old versions of a key. It keeps the newest version of // It removes the old versions of a key. It keeps the newest version of
// the key even if its latest modification index is smaller than the given // the key even if its latest modification index is smaller than the given
// index. // index.
message CompactionRequest { message CompactionRequest {
int64 index = 1; int64 index = 1;

View File

@ -22,7 +22,7 @@ package raftpb
import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto" import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
import math "math" import math "math"
// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" // discarding unused import gogoproto "github.com/coreos/etcd/Godeps/_workspace/src/gogoproto/gogo.pb"
import io "io" import io "io"
import fmt "fmt" import fmt "fmt"

View File

@ -1,7 +1,7 @@
syntax = "proto2"; syntax = "proto2";
package raftpb; package raftpb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true; option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true; option (gogoproto.sizer_all) = true;

View File

@ -22,7 +22,7 @@ export GOBIN=${PWD}/bin
go get github.com/gogo/protobuf/{proto,protoc-gen-gogo,gogoproto} go get github.com/gogo/protobuf/{proto,protoc-gen-gogo,gogoproto}
pushd ${GOPATH}/src/github.com/gogo/protobuf/ pushd ${GOPATH}/src/github.com/gogo/protobuf/
git reset --hard ${SHA} git reset --hard ${SHA}
make make install
popd popd
export PATH="${GOBIN}:${PATH}" export PATH="${GOBIN}:${PATH}"
@ -35,10 +35,17 @@ for dir in ${DIRS}; do
popd popd
done done
COREOS_ROOT="${GOPATH}/src/github.com/coreos"
GOGOPROTO_ROOT="${GOPATH}/src/github.com/gogo/protobuf"
GOGOPROTO_PATH="${GOGOPROTO_ROOT}:${GOGOPROTO_ROOT}/protobuf"
ESCAPED_PREFIX=$(echo $PREFIX | sed -e 's/[\/&]/\\&/g')
for dir in ${DIRS}; do for dir in ${DIRS}; do
pushd ${dir} pushd ${dir}
protoc --gogofast_out=plugins=grpc:. -I=.:${GOPATH}/src/github.com/gogo/protobuf/protobuf:${GOPATH}/src *.proto protoc --gogofast_out=plugins=grpc,import_prefix=github.com/coreos/:. -I=.:"${GOGOPROTO_PATH}":"${COREOS_ROOT}" *.proto
sed -i".bak" -e "s|github.com/gogo/protobuf/proto|${PREFIX}/github.com/gogo/protobuf/proto|" *.go sed -i.bak -E "s/github\.com\/coreos\/(gogoproto|github\.com|golang\.org|google\.golang\.org)/${ESCAPED_PREFIX}\/\1/g" *.pb.go
sed -i.bak -E 's/github\.com\/coreos\/(errors|fmt|io)/\1/g' *.pb.go
rm -f *.bak rm -f *.bak
popd popd
done done

View File

@ -16,7 +16,7 @@ package snappb
import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto" import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
import math "math" import math "math"
// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" // discarding unused import gogoproto "github.com/coreos/etcd/Godeps/_workspace/src/gogoproto/gogo.pb"
import io "io" import io "io"
import fmt "fmt" import fmt "fmt"

View File

@ -1,7 +1,7 @@
syntax = "proto2"; syntax = "proto2";
package snappb; package snappb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true; option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true; option (gogoproto.sizer_all) = true;

View File

@ -16,7 +16,7 @@ package storagepb
import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto" import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" // discarding unused import gogoproto "github.com/coreos/etcd/Godeps/_workspace/src/gogoproto/gogo.pb"
import io "io" import io "io"
import fmt "fmt" import fmt "fmt"
@ -48,10 +48,10 @@ func (x Event_EventType) String() string {
} }
type KeyValue struct { type KeyValue struct {
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
CreateIndex int64 `protobuf:"varint,2,opt,name=create_index,proto3" json:"create_index,omitempty"`
// mod_index is the last modified index of the key. // mod_index is the last modified index of the key.
CreateIndex int64 `protobuf:"varint,2,opt,name=create_index,proto3" json:"create_index,omitempty"` ModIndex int64 `protobuf:"varint,3,opt,name=mod_index,proto3" json:"mod_index,omitempty"`
ModIndex int64 `protobuf:"varint,3,opt,name=mod_index,proto3" json:"mod_index,omitempty"`
// version is the version of the key. A deletion resets // version is the version of the key. A deletion resets
// the version to zero and any modification of the key // the version to zero and any modification of the key
// increases its version. // increases its version.

View File

@ -1,7 +1,7 @@
syntax = "proto3"; syntax = "proto3";
package storagepb; package storagepb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true; option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true; option (gogoproto.sizer_all) = true;

View File

@ -17,7 +17,7 @@ package walpb
import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto" import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
import math "math" import math "math"
// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" // discarding unused import gogoproto "github.com/coreos/etcd/Godeps/_workspace/src/gogoproto/gogo.pb"
import io "io" import io "io"
import fmt "fmt" import fmt "fmt"

View File

@ -1,7 +1,7 @@
syntax = "proto2"; syntax = "proto2";
package walpb; package walpb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true; option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true; option (gogoproto.sizer_all) = true;