From 5f050614e589a8a6ae6bbd4922528c19ba67b916 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 28 Mar 2022 17:17:50 -0400 Subject: [PATCH 1/2] remove the rest of gogo --- .circleci/config.yml | 4 +- GNUmakefile | 4 +- .../private/internal/testservice/simple.pb.go | 483 +--- .../services/subscribe/subscribe_test.go | 7 +- agent/rpcclient/health/view_test.go | 5 +- agent/structs/protobuf_compat.go | 29 - agent/structs/structs.go | 20 - agent/submatview/store_test.go | 12 +- build-support/scripts/proto-gen-entry.sh | 191 +- build-support/scripts/proto-gen-no-gogo.sh | 169 -- build-support/scripts/proto-gen.sh | 74 +- go.mod | 2 +- proto/pbacl/acl.pb.go | 314 +-- proto/pbcommongogo/common.gen.go | 70 - proto/pbcommongogo/common.go | 303 --- proto/pbcommongogo/common.pb.binary.go | 78 - proto/pbcommongogo/common.pb.go | 2036 ----------------- proto/pbcommongogo/common.proto | 182 -- proto/pbcommongogo/common_oss.go | 25 - proto/pbservice/convert_pbstruct.go | 1 - proto/pbutil/pbutil.go | 23 - proto/translate.go | 68 - proto/translate_test.go | 86 - 23 files changed, 273 insertions(+), 3913 deletions(-) mode change 100644 => 100755 build-support/scripts/proto-gen-entry.sh delete mode 100755 build-support/scripts/proto-gen-no-gogo.sh delete mode 100644 proto/pbcommongogo/common.gen.go delete mode 100644 proto/pbcommongogo/common.go delete mode 100644 proto/pbcommongogo/common.pb.binary.go delete mode 100644 proto/pbcommongogo/common.pb.go delete mode 100644 proto/pbcommongogo/common.proto delete mode 100644 proto/pbcommongogo/common_oss.go delete mode 100644 proto/pbutil/pbutil.go delete mode 100644 proto/translate.go delete mode 100644 proto/translate_test.go diff --git a/.circleci/config.yml b/.circleci/config.yml index e637d0d08a..db57fb786e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -235,11 +235,9 @@ jobs: sudo chmod -R a+Xr /usr/local/include/google/ rm protoc-*.zip - run: - name: Install gogo/protobuf + name: Install protobuf command: | - gogo_version=$(go list -m github.com/gogo/protobuf | awk '{print $2}') go install -v github.com/hashicorp/protoc-gen-go-binary@master - go install -v github.com/gogo/protobuf/protoc-gen-gofast@${gogo_version} go install -v github.com/favadi/protoc-go-inject-tag@v1.3.0 go install -v github.com/golang/protobuf/protoc-gen-go@v1.3.5 diff --git a/GNUmakefile b/GNUmakefile index 578e826c58..fa9fcb6009 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,13 +2,11 @@ # https://www.consul.io/docs/install#compiling-from-source SHELL = bash -GOGOVERSION?=$(shell grep github.com/gogo/protobuf go.mod | awk '{print $$2}') GOTOOLS = \ github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs@master \ github.com/hashicorp/go-bindata/go-bindata@master \ golang.org/x/tools/cmd/cover@master \ golang.org/x/tools/cmd/stringer@master \ - github.com/gogo/protobuf/protoc-gen-gofast@$(GOGOVERSION) \ github.com/hashicorp/protoc-gen-go-binary@master \ github.com/vektra/mockery/cmd/mockery@master \ github.com/golangci/golangci-lint/cmd/golangci-lint@v1.40.1 \ @@ -347,7 +345,7 @@ proto: $(PROTOGOFILES) $(PROTOGOBINFILES) %.pb.go %.pb.binary.go: %.proto - @$(SHELL) $(CURDIR)/build-support/scripts/proto-gen-entry.sh --grpc --import-replace "$<" + @$(SHELL) $(CURDIR)/build-support/scripts/proto-gen.sh --grpc --import-replace "$<" .PHONY: module-versions # Print a list of modules which can be updated. diff --git a/agent/grpc/private/internal/testservice/simple.pb.go b/agent/grpc/private/internal/testservice/simple.pb.go index dc2835664f..bfd847a28d 100644 --- a/agent/grpc/private/internal/testservice/simple.pb.go +++ b/agent/grpc/private/internal/testservice/simple.pb.go @@ -1,4 +1,4 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. +// Code generated by protoc-gen-go. DO NOT EDIT. // source: agent/grpc/private/internal/testservice/simple.proto package testservice @@ -10,9 +10,7 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -39,26 +37,18 @@ func (*Req) ProtoMessage() {} func (*Req) Descriptor() ([]byte, []int) { return fileDescriptor_98af0751f806f450, []int{0} } + func (m *Req) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + return xxx_messageInfo_Req.Unmarshal(m, b) } func (m *Req) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Req.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } + return xxx_messageInfo_Req.Marshal(b, m, deterministic) } func (m *Req) XXX_Merge(src proto.Message) { xxx_messageInfo_Req.Merge(m, src) } func (m *Req) XXX_Size() int { - return m.Size() + return xxx_messageInfo_Req.Size(m) } func (m *Req) XXX_DiscardUnknown() { xxx_messageInfo_Req.DiscardUnknown(m) @@ -87,26 +77,18 @@ func (*Resp) ProtoMessage() {} func (*Resp) Descriptor() ([]byte, []int) { return fileDescriptor_98af0751f806f450, []int{1} } + func (m *Resp) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + return xxx_messageInfo_Resp.Unmarshal(m, b) } func (m *Resp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Resp.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } + return xxx_messageInfo_Resp.Marshal(b, m, deterministic) } func (m *Resp) XXX_Merge(src proto.Message) { xxx_messageInfo_Resp.Merge(m, src) } func (m *Resp) XXX_Size() int { - return m.Size() + return xxx_messageInfo_Resp.Size(m) } func (m *Resp) XXX_DiscardUnknown() { xxx_messageInfo_Resp.DiscardUnknown(m) @@ -138,30 +120,28 @@ func init() { } var fileDescriptor_98af0751f806f450 = []byte{ - // 214 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x49, 0x4c, 0x4f, 0xcd, - 0x2b, 0xd1, 0x4f, 0x2f, 0x2a, 0x48, 0xd6, 0x2f, 0x28, 0xca, 0x2c, 0x4b, 0x2c, 0x49, 0xd5, 0xcf, - 0xcc, 0x2b, 0x49, 0x2d, 0xca, 0x4b, 0xcc, 0xd1, 0x2f, 0x49, 0x2d, 0x2e, 0x29, 0x4e, 0x2d, 0x2a, - 0xcb, 0x4c, 0x4e, 0xd5, 0x2f, 0xce, 0xcc, 0x2d, 0xc8, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0xe2, 0x46, 0x92, 0x51, 0x52, 0xe5, 0x62, 0x0e, 0x4a, 0x2d, 0x14, 0x92, 0xe3, 0xe2, 0x72, - 0x49, 0x2c, 0x49, 0x4c, 0x4e, 0x05, 0xe9, 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x42, 0x12, - 0x51, 0x72, 0xe3, 0x62, 0x09, 0x4a, 0x2d, 0x2e, 0x00, 0xa9, 0x0b, 0x4e, 0x2d, 0x2a, 0x4b, 0x2d, - 0xf2, 0x4b, 0xcc, 0x4d, 0x85, 0xa9, 0x43, 0x88, 0xa0, 0x99, 0xc3, 0x84, 0x6e, 0x8e, 0x51, 0x2e, - 0x17, 0x5b, 0x30, 0xd8, 0x2d, 0x42, 0x46, 0x5c, 0x9c, 0xc1, 0xf9, 0xb9, 0xa9, 0x25, 0x19, 0x99, - 0x79, 0xe9, 0x42, 0x02, 0x7a, 0x48, 0x6e, 0xd2, 0x0b, 0x4a, 0x2d, 0x94, 0x12, 0x44, 0x13, 0x29, - 0x2e, 0x50, 0x62, 0x10, 0xd2, 0xe7, 0x62, 0x71, 0xcb, 0xc9, 0x2f, 0x27, 0x52, 0xb9, 0x01, 0xa3, - 0x93, 0xc0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe3, - 0xb1, 0x1c, 0x43, 0x12, 0x1b, 0x38, 0x0c, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x76, 0xce, - 0x88, 0x7d, 0x3b, 0x01, 0x00, 0x00, + // 189 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x8f, 0xcd, 0x0a, 0x82, 0x40, + 0x14, 0x85, 0xb3, 0x44, 0xf0, 0xb6, 0xa9, 0x59, 0x45, 0x8b, 0x08, 0x21, 0x68, 0xe5, 0x84, 0xf5, + 0x08, 0xe1, 0xb2, 0xc5, 0xf8, 0x04, 0x93, 0x5c, 0x6c, 0xc0, 0xf9, 0x71, 0xe6, 0x62, 0xaf, 0x1f, + 0x0a, 0x91, 0xb8, 0x6a, 0xfb, 0xdd, 0xef, 0x1e, 0xce, 0x81, 0x9b, 0x6c, 0xd0, 0x10, 0x6f, 0xbc, + 0xab, 0xb9, 0xf3, 0xaa, 0x97, 0x84, 0x5c, 0x19, 0x42, 0x6f, 0x64, 0xcb, 0x09, 0x03, 0x05, 0xf4, + 0xbd, 0xaa, 0x91, 0x07, 0xa5, 0x5d, 0x8b, 0xb9, 0xf3, 0x96, 0x2c, 0x5b, 0x4f, 0x2e, 0xd9, 0x09, + 0x56, 0x02, 0x3b, 0x76, 0x00, 0xb8, 0x4b, 0x92, 0x35, 0x0e, 0xdf, 0xbb, 0xe8, 0x18, 0x9d, 0x53, + 0x31, 0x21, 0x59, 0x09, 0xb1, 0xc0, 0xe0, 0x06, 0xaf, 0x42, 0xdf, 0xa3, 0x7f, 0x48, 0x8d, 0x5f, + 0xef, 0x47, 0x66, 0x39, 0xcb, 0x79, 0x4e, 0xa1, 0x21, 0xa9, 0xc6, 0x2e, 0xac, 0x80, 0xb4, 0xb2, + 0x1a, 0xe9, 0xa5, 0x4c, 0xc3, 0x36, 0xf9, 0xa4, 0x53, 0x2e, 0xb0, 0xdb, 0x6f, 0x67, 0x24, 0xb8, + 0x6c, 0xc1, 0x38, 0xc4, 0x65, 0x6b, 0xdf, 0x7f, 0xea, 0x97, 0xe8, 0x99, 0x8c, 0x8b, 0xaf, 0x9f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x5c, 0xf5, 0xcb, 0x29, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConn +var _ grpc.ClientConnInterface // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +const _ = grpc.SupportPackageIsVersion6 // SimpleClient is the client API for Simple service. // @@ -172,10 +152,10 @@ type SimpleClient interface { } type simpleClient struct { - cc *grpc.ClientConn + cc grpc.ClientConnInterface } -func NewSimpleClient(cc *grpc.ClientConn) SimpleClient { +func NewSimpleClient(cc grpc.ClientConnInterface) SimpleClient { return &simpleClient{cc} } @@ -298,414 +278,3 @@ var _Simple_serviceDesc = grpc.ServiceDesc{ }, Metadata: "agent/grpc/private/internal/testservice/simple.proto", } - -func (m *Req) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Req) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Req) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Datacenter) > 0 { - i -= len(m.Datacenter) - copy(dAtA[i:], m.Datacenter) - i = encodeVarintSimple(dAtA, i, uint64(len(m.Datacenter))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Resp) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Resp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Resp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Datacenter) > 0 { - i -= len(m.Datacenter) - copy(dAtA[i:], m.Datacenter) - i = encodeVarintSimple(dAtA, i, uint64(len(m.Datacenter))) - i-- - dAtA[i] = 0x12 - } - if len(m.ServerName) > 0 { - i -= len(m.ServerName) - copy(dAtA[i:], m.ServerName) - i = encodeVarintSimple(dAtA, i, uint64(len(m.ServerName))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintSimple(dAtA []byte, offset int, v uint64) int { - offset -= sovSimple(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Req) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Datacenter) - if l > 0 { - n += 1 + l + sovSimple(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Resp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ServerName) - if l > 0 { - n += 1 + l + sovSimple(uint64(l)) - } - l = len(m.Datacenter) - if l > 0 { - n += 1 + l + sovSimple(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovSimple(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozSimple(x uint64) (n int) { - return sovSimple(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Req) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSimple - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Req: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Req: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Datacenter", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSimple - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthSimple - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSimple - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Datacenter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSimple(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSimple - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Resp) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSimple - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Resp: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Resp: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ServerName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSimple - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthSimple - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSimple - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ServerName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Datacenter", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSimple - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthSimple - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSimple - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Datacenter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSimple(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSimple - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipSimple(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowSimple - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowSimple - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowSimple - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthSimple - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupSimple - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthSimple - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthSimple = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowSimple = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupSimple = fmt.Errorf("proto: unexpected end of group") -) diff --git a/agent/grpc/private/services/subscribe/subscribe_test.go b/agent/grpc/private/services/subscribe/subscribe_test.go index 0a52c0f492..aea7669c9a 100644 --- a/agent/grpc/private/services/subscribe/subscribe_test.go +++ b/agent/grpc/private/services/subscribe/subscribe_test.go @@ -26,7 +26,6 @@ import ( grpc "github.com/hashicorp/consul/agent/grpc/private" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/proto/pbcommongogo" "github.com/hashicorp/consul/proto/pbservice" "github.com/hashicorp/consul/proto/pbsubscribe" "github.com/hashicorp/consul/types" @@ -124,7 +123,7 @@ func TestServer_Subscribe_IntegrationWithBackend(t *testing.T) { streamHandle, err := streamClient.Subscribe(ctx, &pbsubscribe.SubscribeRequest{ Topic: pbsubscribe.Topic_ServiceHealth, Key: "redis", - Namespace: pbcommongogo.DefaultEnterpriseMeta.Namespace, + Namespace: pbcommon.DefaultEnterpriseMeta.Namespace, }) require.NoError(t, err) @@ -489,7 +488,7 @@ func TestServer_Subscribe_IntegrationWithBackend_ForwardToDC(t *testing.T) { Topic: pbsubscribe.Topic_ServiceHealth, Key: "redis", Datacenter: "dc2", - Namespace: pbcommongogo.DefaultEnterpriseMeta.Namespace, + Namespace: pbcommon.DefaultEnterpriseMeta.Namespace, }) require.NoError(t, err) go recvEvents(chEvents, streamHandle) @@ -746,7 +745,7 @@ node "node1" { Topic: pbsubscribe.Topic_ServiceHealth, Key: "foo", Token: token, - Namespace: pbcommongogo.DefaultEnterpriseMeta.Namespace, + Namespace: pbcommon.DefaultEnterpriseMeta.Namespace, }) require.NoError(t, err) diff --git a/agent/rpcclient/health/view_test.go b/agent/rpcclient/health/view_test.go index 9dc00150f7..96bae37a18 100644 --- a/agent/rpcclient/health/view_test.go +++ b/agent/rpcclient/health/view_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "github.com/hashicorp/consul/proto/pbcommon" "strings" "testing" "time" @@ -18,7 +17,7 @@ import ( "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/submatview" - "github.com/hashicorp/consul/proto/pbcommongogo" + "github.com/hashicorp/consul/proto/pbcommon" "github.com/hashicorp/consul/proto/pbservice" "github.com/hashicorp/consul/proto/pbsubscribe" "github.com/hashicorp/consul/types" @@ -75,7 +74,7 @@ func TestHealthView_IntegrationWithStore_WithEmptySnapshot(t *testing.T) { t.Skip("too slow for testing.Short") } - namespace := getNamespace(pbcommongogo.DefaultEnterpriseMeta.Namespace) + namespace := getNamespace(pbcommon.DefaultEnterpriseMeta.Namespace) streamClient := newStreamClient(validateNamespace(namespace)) ctx, cancel := context.WithCancel(context.Background()) diff --git a/agent/structs/protobuf_compat.go b/agent/structs/protobuf_compat.go index 860d971c35..e3a01cadf5 100644 --- a/agent/structs/protobuf_compat.go +++ b/agent/structs/protobuf_compat.go @@ -5,7 +5,6 @@ import ( ) // GetToken helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetToken() string { if m != nil { return m.Token @@ -14,7 +13,6 @@ func (m *QueryOptions) GetToken() string { } // GetMinQueryIndex helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetMinQueryIndex() uint64 { if m != nil { return m.MinQueryIndex @@ -23,7 +21,6 @@ func (m *QueryOptions) GetMinQueryIndex() uint64 { } // GetMaxQueryTime helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetMaxQueryTime() (time.Duration, error) { if m != nil { return m.MaxQueryTime, nil @@ -32,7 +29,6 @@ func (m *QueryOptions) GetMaxQueryTime() (time.Duration, error) { } // GetAllowStale helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetAllowStale() bool { if m != nil { return m.AllowStale @@ -41,7 +37,6 @@ func (m *QueryOptions) GetAllowStale() bool { } // GetRequireConsistent helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetRequireConsistent() bool { if m != nil { return m.RequireConsistent @@ -50,7 +45,6 @@ func (m *QueryOptions) GetRequireConsistent() bool { } // GetUseCache helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetUseCache() bool { if m != nil { return m.UseCache @@ -59,7 +53,6 @@ func (m *QueryOptions) GetUseCache() bool { } // GetMaxStaleDuration helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetMaxStaleDuration() (time.Duration, error) { if m != nil { return m.MaxStaleDuration, nil @@ -68,7 +61,6 @@ func (m *QueryOptions) GetMaxStaleDuration() (time.Duration, error) { } // GetMaxAge helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetMaxAge() (time.Duration, error) { if m != nil { return m.MaxAge, nil @@ -77,7 +69,6 @@ func (m *QueryOptions) GetMaxAge() (time.Duration, error) { } // GetMustRevalidate helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetMustRevalidate() bool { if m != nil { return m.MustRevalidate @@ -86,7 +77,6 @@ func (m *QueryOptions) GetMustRevalidate() bool { } // GetStaleIfError helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetStaleIfError() (time.Duration, error) { if m != nil { return m.StaleIfError, nil @@ -95,7 +85,6 @@ func (m *QueryOptions) GetStaleIfError() (time.Duration, error) { } // GetFilter helps implement the QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryOptions) GetFilter() string { if m != nil { return m.Filter @@ -104,67 +93,56 @@ func (m *QueryOptions) GetFilter() string { } // SetToken is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetToken(token string) { q.Token = token } // SetMinQueryIndex is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetMinQueryIndex(minQueryIndex uint64) { q.MinQueryIndex = minQueryIndex } // SetMaxQueryTime is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetMaxQueryTime(maxQueryTime time.Duration) { q.MaxQueryTime = maxQueryTime } // SetAllowStale is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetAllowStale(allowStale bool) { q.AllowStale = allowStale } // SetRequireConsistent is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetRequireConsistent(requireConsistent bool) { q.RequireConsistent = requireConsistent } // SetUseCache is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetUseCache(useCache bool) { q.UseCache = useCache } // SetMaxStaleDuration is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetMaxStaleDuration(maxStaleDuration time.Duration) { q.MaxStaleDuration = maxStaleDuration } // SetMaxAge is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetMaxAge(maxAge time.Duration) { q.MaxAge = maxAge } // SetMustRevalidate is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetMustRevalidate(mustRevalidate bool) { q.MustRevalidate = mustRevalidate } // SetStaleIfError is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetStaleIfError(staleIfError time.Duration) { q.StaleIfError = staleIfError } // SetFilter is needed to implement the structs.QueryOptionsCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryOptions) SetFilter(filter string) { q.Filter = filter } @@ -178,7 +156,6 @@ func (m *QueryMeta) GetIndex() uint64 { } // GetLastContact helps implement the QueryMetaCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryMeta) GetLastContact() (time.Duration, error) { if m != nil { return m.LastContact, nil @@ -187,7 +164,6 @@ func (m *QueryMeta) GetLastContact() (time.Duration, error) { } // GetKnownLeader helps implement the QueryMetaCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryMeta) GetKnownLeader() bool { if m != nil { return m.KnownLeader @@ -196,7 +172,6 @@ func (m *QueryMeta) GetKnownLeader() bool { } // GetConsistencyLevel helps implement the QueryMetaCompat interface -// Copied from proto/pbcommongogo/common.pb.go func (m *QueryMeta) GetConsistencyLevel() string { if m != nil { return m.ConsistencyLevel @@ -205,25 +180,21 @@ func (m *QueryMeta) GetConsistencyLevel() string { } // SetLastContact is needed to implement the structs.QueryMetaCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryMeta) SetLastContact(lastContact time.Duration) { q.LastContact = lastContact } // SetKnownLeader is needed to implement the structs.QueryMetaCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryMeta) SetKnownLeader(knownLeader bool) { q.KnownLeader = knownLeader } // SetIndex is needed to implement the structs.QueryMetaCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryMeta) SetIndex(index uint64) { q.Index = index } // SetConsistencyLevel is needed to implement the structs.QueryMetaCompat interface -// Copied from proto/pbcommongogo/common.go func (q *QueryMeta) SetConsistencyLevel(consistencyLevel string) { q.ConsistencyLevel = consistencyLevel } diff --git a/agent/structs/structs.go b/agent/structs/structs.go index 96af7c4719..80f27dd95b 100644 --- a/agent/structs/structs.go +++ b/agent/structs/structs.go @@ -22,7 +22,6 @@ import ( "github.com/hashicorp/serf/coordinate" "github.com/mitchellh/hashstructure" - gtype "github.com/gogo/protobuf/types" ptypes "github.com/golang/protobuf/ptypes" "github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/agent/cache" @@ -2686,25 +2685,6 @@ func (m MessageType) String() string { } -func DurationToProtoGogo(d time.Duration) gtype.Duration { - return *gtype.DurationProto(d) -} - -func DurationFromProtoGogo(d gtype.Duration) time.Duration { - duration, _ := gtype.DurationFromProto(&d) - return duration -} - -func TimeFromProtoGogo(s *gtype.Timestamp) time.Time { - time, _ := gtype.TimestampFromProto(s) - return time -} - -func TimeToProtoGogo(s time.Time) *gtype.Timestamp { - proto, _ := gtype.TimestampProto(s) - return proto -} - func DurationToProto(d time.Duration) *duration.Duration { return ptypes.DurationProto(d) } diff --git a/agent/submatview/store_test.go b/agent/submatview/store_test.go index 2055cf9111..93b04d1e80 100644 --- a/agent/submatview/store_test.go +++ b/agent/submatview/store_test.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/consul/agent/cache" "github.com/hashicorp/consul/lib/ttlcache" - "github.com/hashicorp/consul/proto/pbcommongogo" + "github.com/hashicorp/consul/proto/pbcommon" "github.com/hashicorp/consul/proto/pbservice" "github.com/hashicorp/consul/proto/pbsubscribe" "github.com/hashicorp/consul/sdk/testutil/retry" @@ -25,7 +25,7 @@ func TestStore_Get(t *testing.T) { go store.Run(ctx) req := &fakeRequest{ - client: NewTestStreamingClient(pbcommongogo.DefaultEnterpriseMeta.Namespace), + client: NewTestStreamingClient(pbcommon.DefaultEnterpriseMeta.Namespace), } req.client.QueueEvents( newEndOfSnapshotEvent(2), @@ -232,7 +232,7 @@ func (r *fakeRequest) NewMaterializer() (*Materializer, error) { Token: "abcd", Datacenter: "dc1", Index: index, - Namespace: pbcommongogo.DefaultEnterpriseMeta.Namespace, + Namespace: pbcommon.DefaultEnterpriseMeta.Namespace, } return req }, @@ -292,7 +292,7 @@ func TestStore_Notify(t *testing.T) { go store.Run(ctx) req := &fakeRequest{ - client: NewTestStreamingClient(pbcommongogo.DefaultEnterpriseMeta.Namespace), + client: NewTestStreamingClient(pbcommon.DefaultEnterpriseMeta.Namespace), } req.client.QueueEvents( newEndOfSnapshotEvent(2), @@ -361,7 +361,7 @@ func TestStore_Notify_ManyRequests(t *testing.T) { go store.Run(ctx) req := &fakeRequest{ - client: NewTestStreamingClient(pbcommongogo.DefaultEnterpriseMeta.Namespace), + client: NewTestStreamingClient(pbcommon.DefaultEnterpriseMeta.Namespace), } req.client.QueueEvents(newEndOfSnapshotEvent(2)) @@ -473,7 +473,7 @@ func TestStore_Run_ExpiresEntries(t *testing.T) { go store.Run(ctx) req := &fakeRequest{ - client: NewTestStreamingClient(pbcommongogo.DefaultEnterpriseMeta.Namespace), + client: NewTestStreamingClient(pbcommon.DefaultEnterpriseMeta.Namespace), } req.client.QueueEvents(newEndOfSnapshotEvent(2)) diff --git a/build-support/scripts/proto-gen-entry.sh b/build-support/scripts/proto-gen-entry.sh old mode 100644 new mode 100755 index 639f725ccc..50d51be0df --- a/build-support/scripts/proto-gen-entry.sh +++ b/build-support/scripts/proto-gen-entry.sh @@ -1,26 +1,169 @@ #!/usr/bin/env bash -FILENAME=$3 -echo $PWD -if [[ "$FILENAME" =~ .*pbcommon/.* ]]; then - echo "$FILENAME no gogo" - ./build-support/scripts/proto-gen-no-gogo.sh $1 $2 $3 -elif [[ "$FILENAME" =~ .*pbconnect/.* ]]; then - echo "$FILENAME no gogo" - ./build-support/scripts/proto-gen-no-gogo.sh $1 $2 $3 -elif [[ "$FILENAME" =~ .*pbconfig/.* ]]; then - echo "$FILENAME no gogo" - ./build-support/scripts/proto-gen-no-gogo.sh $1 $2 $3 -elif [[ "$FILENAME" =~ .*pbautoconf/.* ]]; then - echo "$FILENAME no gogo" - ./build-support/scripts/proto-gen-no-gogo.sh $1 $2 $3 -elif [[ "$FILENAME" =~ .*pbservice/.* ]]; then - echo "$FILENAME no gogo" - ./build-support/scripts/proto-gen-no-gogo.sh $1 $2 $3 -elif [[ "$FILENAME" =~ .*pbsubscribe/.* ]]; then - echo "$FILENAME no gogo" - ./build-support/scripts/proto-gen-no-gogo.sh $1 $2 $3 -else - echo "$FILENAME gogo" - ./build-support/scripts/proto-gen.sh $1 $2 $3 -fi \ No newline at end of file +SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" +pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null +SCRIPT_DIR=$(pwd) +pushd ../.. > /dev/null +SOURCE_DIR=$(pwd) +popd > /dev/null +pushd ../functions > /dev/null +FN_DIR=$(pwd) +popd > /dev/null +popd > /dev/null + +source "${SCRIPT_DIR}/functions.sh" + +function usage { +cat <<-EOF +Usage: ${SCRIPT_NAME} [] + +Description: + Generate the Go files from protobuf definitions. In addition to + running the protoc generator it will also fixup build tags in the + generated code. + +Options: + --import-replace Replace imports of google types with those from the protobuf repo. + --grpc Enable the gRPC plugin + -h | --help Print this help text. +EOF +} + +function err_usage { + err "$1" + err "" + err "$(usage)" +} + +function main { + local -i grpc=0 + local -i imp_replace=0 + local proto_path= + + while test $# -gt 0 + do + case "$1" in + -h | --help ) + usage + return 0 + ;; + --grpc ) + grpc=1 + shift + ;; + --import-replace ) + imp_replace=1 + shift + ;; + * ) + proto_path="$1" + shift + ;; + esac + done + + if test -z "${proto_path}" + then + err_usage "ERROR: No proto file specified" + return 1 + fi + + go mod download + + local golang_proto_path=$(go list -f '{{ .Dir }}' -m github.com/golang/protobuf) + local golang_proto_mod_path=$(sed -e 's,\(.*\)github.com.*,\1,' <<< "${golang_proto_path}") + + + local golang_proto_imp_replace="Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp" + golang_proto_imp_replace="${golang_proto_imp_replace},Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration" + + local proto_go_path=${proto_path%%.proto}.pb.go + local proto_go_bin_path=${proto_path%%.proto}.pb.binary.go + local proto_go_rpcglue_path=${proto_path%%.proto}.rpcglue.pb.go + + local go_proto_out="paths=source_relative" + if is_set "${grpc}" + then + go_proto_out="${go_proto_out},plugins=grpc" + fi + + if is_set "${imp_replace}" + then + go_proto_out="${go_proto_out},${golang_proto_imp_replace}" + fi + + if test -n "${go_proto_out}" + then + go_proto_out="${go_proto_out}:" + fi + + # How we run protoc probably needs some documentation. + # + # This is the path to where + # -I="${golang_proto_path}/protobuf" \ + local -i ret=0 + status_stage "Generating ${proto_path} into ${proto_go_path} and ${proto_go_bin_path} (NO GOGO)" + echo "debug_run protoc \ + -I=\"${golang_proto_path}\" \ + -I=\"${golang_proto_mod_path}\" \ + -I=\"${SOURCE_DIR}\" \ + --go_out=\"${go_proto_out}${SOURCE_DIR}\" \ + --go-binary_out=\"${SOURCE_DIR}\" \ + \"${proto_path}\"" + debug_run protoc \ + -I="${golang_proto_path}" \ + -I="${golang_proto_mod_path}" \ + -I="${SOURCE_DIR}" \ + --go_out="${go_proto_out}${SOURCE_DIR}" \ + --go-binary_out="${SOURCE_DIR}" \ + "${proto_path}" + + if test $? -ne 0 + then + err "Failed to run protoc for ${proto_path}" + return 1 + fi + + debug_run protoc-go-inject-tag \ + -input="${proto_go_path}" + + if test $? -ne 0 + then + err "Failed to run protoc-go-inject-tag for ${proto_path}" + return 1 + fi + + echo "debug_run protoc \ + -I=\"${golang_proto_path}\" \ + -I=\"${golang_proto_mod_path}\" \ + -I=\"${SOURCE_DIR}\" \ + --go_out=\"${go_proto_out}${SOURCE_DIR}\" \ + --go-binary_out=\"${SOURCE_DIR}\" \ + \"${proto_path}\"" + + BUILD_TAGS=$(sed -e '/^[[:space:]]*$/,$d' < "${proto_path}" | grep '// +build') + if test -n "${BUILD_TAGS}" + then + echo -e "${BUILD_TAGS}\n" >> "${proto_go_path}.new" + cat "${proto_go_path}" >> "${proto_go_path}.new" + mv "${proto_go_path}.new" "${proto_go_path}" + + echo -e "${BUILD_TAGS}\n" >> "${proto_go_bin_path}.new" + cat "${proto_go_bin_path}" >> "${proto_go_bin_path}.new" + mv "${proto_go_bin_path}.new" "${proto_go_bin_path}" + fi + + # note: this has to run after we fix up the build tags above + rm -f "${proto_go_rpcglue_path}" + debug_run go run ./internal/tools/proto-gen-rpc-glue/main.go -path "${proto_go_path}" + if test $? -ne 0 + then + err "Failed to generate consul rpc glue outputs from ${proto_path}" + return 1 + fi + + return 0 +} + +main "$@" +exit $? diff --git a/build-support/scripts/proto-gen-no-gogo.sh b/build-support/scripts/proto-gen-no-gogo.sh deleted file mode 100755 index 50d51be0df..0000000000 --- a/build-support/scripts/proto-gen-no-gogo.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" -pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null -SCRIPT_DIR=$(pwd) -pushd ../.. > /dev/null -SOURCE_DIR=$(pwd) -popd > /dev/null -pushd ../functions > /dev/null -FN_DIR=$(pwd) -popd > /dev/null -popd > /dev/null - -source "${SCRIPT_DIR}/functions.sh" - -function usage { -cat <<-EOF -Usage: ${SCRIPT_NAME} [] - -Description: - Generate the Go files from protobuf definitions. In addition to - running the protoc generator it will also fixup build tags in the - generated code. - -Options: - --import-replace Replace imports of google types with those from the protobuf repo. - --grpc Enable the gRPC plugin - -h | --help Print this help text. -EOF -} - -function err_usage { - err "$1" - err "" - err "$(usage)" -} - -function main { - local -i grpc=0 - local -i imp_replace=0 - local proto_path= - - while test $# -gt 0 - do - case "$1" in - -h | --help ) - usage - return 0 - ;; - --grpc ) - grpc=1 - shift - ;; - --import-replace ) - imp_replace=1 - shift - ;; - * ) - proto_path="$1" - shift - ;; - esac - done - - if test -z "${proto_path}" - then - err_usage "ERROR: No proto file specified" - return 1 - fi - - go mod download - - local golang_proto_path=$(go list -f '{{ .Dir }}' -m github.com/golang/protobuf) - local golang_proto_mod_path=$(sed -e 's,\(.*\)github.com.*,\1,' <<< "${golang_proto_path}") - - - local golang_proto_imp_replace="Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp" - golang_proto_imp_replace="${golang_proto_imp_replace},Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration" - - local proto_go_path=${proto_path%%.proto}.pb.go - local proto_go_bin_path=${proto_path%%.proto}.pb.binary.go - local proto_go_rpcglue_path=${proto_path%%.proto}.rpcglue.pb.go - - local go_proto_out="paths=source_relative" - if is_set "${grpc}" - then - go_proto_out="${go_proto_out},plugins=grpc" - fi - - if is_set "${imp_replace}" - then - go_proto_out="${go_proto_out},${golang_proto_imp_replace}" - fi - - if test -n "${go_proto_out}" - then - go_proto_out="${go_proto_out}:" - fi - - # How we run protoc probably needs some documentation. - # - # This is the path to where - # -I="${golang_proto_path}/protobuf" \ - local -i ret=0 - status_stage "Generating ${proto_path} into ${proto_go_path} and ${proto_go_bin_path} (NO GOGO)" - echo "debug_run protoc \ - -I=\"${golang_proto_path}\" \ - -I=\"${golang_proto_mod_path}\" \ - -I=\"${SOURCE_DIR}\" \ - --go_out=\"${go_proto_out}${SOURCE_DIR}\" \ - --go-binary_out=\"${SOURCE_DIR}\" \ - \"${proto_path}\"" - debug_run protoc \ - -I="${golang_proto_path}" \ - -I="${golang_proto_mod_path}" \ - -I="${SOURCE_DIR}" \ - --go_out="${go_proto_out}${SOURCE_DIR}" \ - --go-binary_out="${SOURCE_DIR}" \ - "${proto_path}" - - if test $? -ne 0 - then - err "Failed to run protoc for ${proto_path}" - return 1 - fi - - debug_run protoc-go-inject-tag \ - -input="${proto_go_path}" - - if test $? -ne 0 - then - err "Failed to run protoc-go-inject-tag for ${proto_path}" - return 1 - fi - - echo "debug_run protoc \ - -I=\"${golang_proto_path}\" \ - -I=\"${golang_proto_mod_path}\" \ - -I=\"${SOURCE_DIR}\" \ - --go_out=\"${go_proto_out}${SOURCE_DIR}\" \ - --go-binary_out=\"${SOURCE_DIR}\" \ - \"${proto_path}\"" - - BUILD_TAGS=$(sed -e '/^[[:space:]]*$/,$d' < "${proto_path}" | grep '// +build') - if test -n "${BUILD_TAGS}" - then - echo -e "${BUILD_TAGS}\n" >> "${proto_go_path}.new" - cat "${proto_go_path}" >> "${proto_go_path}.new" - mv "${proto_go_path}.new" "${proto_go_path}" - - echo -e "${BUILD_TAGS}\n" >> "${proto_go_bin_path}.new" - cat "${proto_go_bin_path}" >> "${proto_go_bin_path}.new" - mv "${proto_go_bin_path}.new" "${proto_go_bin_path}" - fi - - # note: this has to run after we fix up the build tags above - rm -f "${proto_go_rpcglue_path}" - debug_run go run ./internal/tools/proto-gen-rpc-glue/main.go -path "${proto_go_path}" - if test $? -ne 0 - then - err "Failed to generate consul rpc glue outputs from ${proto_path}" - return 1 - fi - - return 0 -} - -main "$@" -exit $? diff --git a/build-support/scripts/proto-gen.sh b/build-support/scripts/proto-gen.sh index 82230bb745..4ecf9acd86 100755 --- a/build-support/scripts/proto-gen.sh +++ b/build-support/scripts/proto-gen.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash + SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null SCRIPT_DIR=$(pwd) @@ -22,7 +23,7 @@ Description: generated code. Options: - --import-replace Replace imports of google types with those from the gogo/protobuf repo. + --import-replace Replace imports of google types with those from the protobuf repo. --grpc Enable the gRPC plugin -h | --help Print this help text. EOF @@ -67,21 +68,19 @@ function main { return 1 fi - local gogo_proto_path=$(go list -f '{{ .Dir }}' -m github.com/gogo/protobuf) - local gogo_proto_mod_path=$(sed -e 's,\(.*\)github.com.*,\1,' <<< "${gogo_proto_path}") + go mod download - local gogo_proto_imp_replace="Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types" - gogo_proto_imp_replace="${gogo_proto_imp_replace},Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types" - gogo_proto_imp_replace="${gogo_proto_imp_replace},Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types" - gogo_proto_imp_replace="${gogo_proto_imp_replace},Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types" - gogo_proto_imp_replace="${gogo_proto_imp_replace},Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types" - gogo_proto_imp_replace="${gogo_proto_imp_replace},Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api" - gogo_proto_imp_replace="${gogo_proto_imp_replace},Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types" - gogo_proto_imp_replace="${gogo_proto_imp_replace},Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types" + local golang_proto_path=$(go list -f '{{ .Dir }}' -m github.com/golang/protobuf) + local golang_proto_mod_path=$(sed -e 's,\(.*\)github.com.*,\1,' <<< "${golang_proto_path}") + + + local golang_proto_imp_replace="Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp" + golang_proto_imp_replace="${golang_proto_imp_replace},Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration" local proto_go_path=${proto_path%%.proto}.pb.go local proto_go_bin_path=${proto_path%%.proto}.pb.binary.go - + local proto_go_rpcglue_path=${proto_path%%.proto}.rpcglue.pb.go + local go_proto_out="paths=source_relative" if is_set "${grpc}" then @@ -90,7 +89,7 @@ function main { if is_set "${imp_replace}" then - go_proto_out="${go_proto_out},${gogo_proto_imp_replace}" + go_proto_out="${go_proto_out},${golang_proto_imp_replace}" fi if test -n "${go_proto_out}" @@ -100,36 +99,69 @@ function main { # How we run protoc probably needs some documentation. # - # This is the path to where - # -I="${gogo_proto_path}/protobuf" \ + # This is the path to where + # -I="${golang_proto_path}/protobuf" \ local -i ret=0 status_stage "Generating ${proto_path} into ${proto_go_path} and ${proto_go_bin_path}" + echo "debug_run protoc \ + -I=\"${golang_proto_path}\" \ + -I=\"${golang_proto_mod_path}\" \ + -I=\"${SOURCE_DIR}\" \ + --go_out=\"${go_proto_out}${SOURCE_DIR}\" \ + --go-binary_out=\"${SOURCE_DIR}\" \ + \"${proto_path}\"" debug_run protoc \ - -I="${gogo_proto_path}/protobuf" \ - -I="${gogo_proto_path}" \ - -I="${gogo_proto_mod_path}" \ + -I="${golang_proto_path}" \ + -I="${golang_proto_mod_path}" \ -I="${SOURCE_DIR}" \ - --gofast_out="${go_proto_out}${SOURCE_DIR}" \ + --go_out="${go_proto_out}${SOURCE_DIR}" \ --go-binary_out="${SOURCE_DIR}" \ "${proto_path}" + if test $? -ne 0 then - err "Failed to generate outputs from ${proto_path}" + err "Failed to run protoc for ${proto_path}" return 1 fi + debug_run protoc-go-inject-tag \ + -input="${proto_go_path}" + + if test $? -ne 0 + then + err "Failed to run protoc-go-inject-tag for ${proto_path}" + return 1 + fi + + echo "debug_run protoc \ + -I=\"${golang_proto_path}\" \ + -I=\"${golang_proto_mod_path}\" \ + -I=\"${SOURCE_DIR}\" \ + --go_out=\"${go_proto_out}${SOURCE_DIR}\" \ + --go-binary_out=\"${SOURCE_DIR}\" \ + \"${proto_path}\"" + BUILD_TAGS=$(sed -e '/^[[:space:]]*$/,$d' < "${proto_path}" | grep '// +build') if test -n "${BUILD_TAGS}" then echo -e "${BUILD_TAGS}\n" >> "${proto_go_path}.new" cat "${proto_go_path}" >> "${proto_go_path}.new" mv "${proto_go_path}.new" "${proto_go_path}" - + echo -e "${BUILD_TAGS}\n" >> "${proto_go_bin_path}.new" cat "${proto_go_bin_path}" >> "${proto_go_bin_path}.new" mv "${proto_go_bin_path}.new" "${proto_go_bin_path}" fi + # note: this has to run after we fix up the build tags above + rm -f "${proto_go_rpcglue_path}" + debug_run go run ./internal/tools/proto-gen-rpc-glue/main.go -path "${proto_go_path}" + if test $? -ne 0 + then + err "Failed to generate consul rpc glue outputs from ${proto_path}" + return 1 + fi + return 0 } diff --git a/go.mod b/go.mod index 628a30202d..e438f1bf2e 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/envoyproxy/go-control-plane v0.9.5 github.com/frankban/quicktest v1.11.0 // indirect github.com/fsnotify/fsnotify v1.5.1 - github.com/gogo/protobuf v1.3.2 + github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.3.5 github.com/google/go-cmp v0.5.6 github.com/google/go-querystring v1.0.0 // indirect diff --git a/proto/pbacl/acl.pb.go b/proto/pbacl/acl.pb.go index d91f00ed58..baaa994e97 100644 --- a/proto/pbacl/acl.pb.go +++ b/proto/pbacl/acl.pb.go @@ -1,4 +1,4 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. +// Code generated by protoc-gen-go. DO NOT EDIT. // source: proto/pbacl/acl.proto package pbacl @@ -6,9 +6,7 @@ package pbacl import ( fmt "fmt" proto "github.com/golang/protobuf/proto" - io "io" math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -37,26 +35,18 @@ func (*ACLLink) ProtoMessage() {} func (*ACLLink) Descriptor() ([]byte, []int) { return fileDescriptor_ad2d2c73a6a0d8b5, []int{0} } + func (m *ACLLink) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + return xxx_messageInfo_ACLLink.Unmarshal(m, b) } func (m *ACLLink) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ACLLink.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } + return xxx_messageInfo_ACLLink.Marshal(b, m, deterministic) } func (m *ACLLink) XXX_Merge(src proto.Message) { xxx_messageInfo_ACLLink.Merge(m, src) } func (m *ACLLink) XXX_Size() int { - return m.Size() + return xxx_messageInfo_ACLLink.Size(m) } func (m *ACLLink) XXX_DiscardUnknown() { xxx_messageInfo_ACLLink.DiscardUnknown(m) @@ -82,296 +72,18 @@ func init() { proto.RegisterType((*ACLLink)(nil), "acl.ACLLink") } -func init() { proto.RegisterFile("proto/pbacl/acl.proto", fileDescriptor_ad2d2c73a6a0d8b5) } +func init() { + proto.RegisterFile("proto/pbacl/acl.proto", fileDescriptor_ad2d2c73a6a0d8b5) +} var fileDescriptor_ad2d2c73a6a0d8b5 = []byte{ - // 145 bytes of a gzipped FileDescriptorProto + // 128 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x48, 0x4a, 0x4c, 0xce, 0xd1, 0x4f, 0x4c, 0xce, 0xd1, 0x03, 0xf3, 0x85, 0x98, 0x13, 0x93, 0x73, 0x94, 0x74, 0xb9, 0xd8, 0x1d, 0x9d, 0x7d, 0x7c, 0x32, 0xf3, 0xb2, 0x85, 0xf8, 0xb8, 0x98, 0x3c, 0x5d, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x98, 0x3c, 0x5d, 0x84, 0x84, - 0xb8, 0x58, 0xfc, 0x12, 0x73, 0x53, 0x25, 0x98, 0xc0, 0x22, 0x60, 0xb6, 0x93, 0xe5, 0x89, 0x47, - 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe3, 0xb1, 0x1c, 0x43, 0x94, - 0x7a, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x46, 0x62, 0x71, 0x46, - 0x66, 0x72, 0x7e, 0x51, 0x81, 0x7e, 0x72, 0x7e, 0x5e, 0x71, 0x69, 0x8e, 0x3e, 0x92, 0xc5, 0x49, - 0x6c, 0x60, 0x8e, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x1b, 0xe6, 0xfd, 0xff, 0x8e, 0x00, 0x00, - 0x00, + 0xb8, 0x58, 0xfc, 0x12, 0x73, 0x53, 0x25, 0x98, 0xc0, 0x22, 0x60, 0xb6, 0x93, 0x66, 0x94, 0x7a, + 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x46, 0x62, 0x71, 0x46, 0x66, + 0x72, 0x7e, 0x51, 0x81, 0x7e, 0x72, 0x7e, 0x5e, 0x71, 0x69, 0x8e, 0x3e, 0x92, 0x45, 0x49, 0x6c, + 0x60, 0x8e, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x25, 0x54, 0x7f, 0x7e, 0x00, 0x00, 0x00, } - -func (m *ACLLink) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ACLLink) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLLink) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintAcl(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x12 - } - if len(m.ID) > 0 { - i -= len(m.ID) - copy(dAtA[i:], m.ID) - i = encodeVarintAcl(dAtA, i, uint64(len(m.ID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintAcl(dAtA []byte, offset int, v uint64) int { - offset -= sovAcl(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ACLLink) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ID) - if l > 0 { - n += 1 + l + sovAcl(uint64(l)) - } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovAcl(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovAcl(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozAcl(x uint64) (n int) { - return sovAcl(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ACLLink) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAcl - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLLink: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLLink: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAcl - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAcl - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAcl - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAcl - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAcl - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAcl - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAcl(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAcl - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipAcl(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowAcl - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowAcl - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowAcl - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthAcl - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupAcl - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthAcl - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthAcl = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowAcl = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupAcl = fmt.Errorf("proto: unexpected end of group") -) diff --git a/proto/pbcommongogo/common.gen.go b/proto/pbcommongogo/common.gen.go deleted file mode 100644 index 925ebb70dc..0000000000 --- a/proto/pbcommongogo/common.gen.go +++ /dev/null @@ -1,70 +0,0 @@ -// Code generated by mog. DO NOT EDIT. - -package pbcommongogo - -import "github.com/hashicorp/consul/agent/structs" - -func QueryMetaToStructs(s *QueryMeta, t *structs.QueryMeta) { - if s == nil { - return - } - t.Index = s.Index - t.LastContact = structs.DurationFromProtoGogo(s.LastContact) - t.KnownLeader = s.KnownLeader - t.ConsistencyLevel = s.ConsistencyLevel - t.ResultsFilteredByACLs = s.ResultsFilteredByACLs -} -func QueryMetaFromStructs(t *structs.QueryMeta, s *QueryMeta) { - if s == nil { - return - } - s.Index = t.Index - s.LastContact = structs.DurationToProtoGogo(t.LastContact) - s.KnownLeader = t.KnownLeader - s.ConsistencyLevel = t.ConsistencyLevel - s.ResultsFilteredByACLs = t.ResultsFilteredByACLs -} -func QueryOptionsToStructs(s *QueryOptions, t *structs.QueryOptions) { - if s == nil { - return - } - t.Token = s.Token - t.MinQueryIndex = s.MinQueryIndex - t.MaxQueryTime = structs.DurationFromProtoGogo(s.MaxQueryTime) - t.AllowStale = s.AllowStale - t.RequireConsistent = s.RequireConsistent - t.UseCache = s.UseCache - t.MaxStaleDuration = structs.DurationFromProtoGogo(s.MaxStaleDuration) - t.MaxAge = structs.DurationFromProtoGogo(s.MaxAge) - t.MustRevalidate = s.MustRevalidate - t.Filter = s.Filter -} -func QueryOptionsFromStructs(t *structs.QueryOptions, s *QueryOptions) { - if s == nil { - return - } - s.Token = t.Token - s.MinQueryIndex = t.MinQueryIndex - s.MaxQueryTime = structs.DurationToProtoGogo(t.MaxQueryTime) - s.AllowStale = t.AllowStale - s.RequireConsistent = t.RequireConsistent - s.UseCache = t.UseCache - s.MaxStaleDuration = structs.DurationToProtoGogo(t.MaxStaleDuration) - s.MaxAge = structs.DurationToProtoGogo(t.MaxAge) - s.MustRevalidate = t.MustRevalidate - s.Filter = t.Filter -} -func RaftIndexToStructs(s *RaftIndex, t *structs.RaftIndex) { - if s == nil { - return - } - t.CreateIndex = s.CreateIndex - t.ModifyIndex = s.ModifyIndex -} -func RaftIndexFromStructs(t *structs.RaftIndex, s *RaftIndex) { - if s == nil { - return - } - s.CreateIndex = t.CreateIndex - s.ModifyIndex = t.ModifyIndex -} diff --git a/proto/pbcommongogo/common.go b/proto/pbcommongogo/common.go deleted file mode 100644 index 5cd6d4d64e..0000000000 --- a/proto/pbcommongogo/common.go +++ /dev/null @@ -1,303 +0,0 @@ -package pbcommongogo - -import ( - "time" - - "github.com/hashicorp/consul/agent/structs" -) - -// IsRead is always true for QueryOption -func (q *QueryOptions) IsRead() bool { - return true -} - -// AllowStaleRead returns whether a stale read should be allowed -func (q *QueryOptions) AllowStaleRead() bool { - return q.AllowStale -} - -func (q *QueryOptions) TokenSecret() string { - return q.Token -} - -func (q *QueryOptions) SetTokenSecret(s string) { - q.Token = s -} - -// SetToken is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetToken(token string) { - q.Token = token -} - -// SetMinQueryIndex is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetMinQueryIndex(minQueryIndex uint64) { - q.MinQueryIndex = minQueryIndex -} - -// SetMaxQueryTime is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetMaxQueryTime(maxQueryTime time.Duration) { - q.MaxQueryTime = structs.DurationToProtoGogo(maxQueryTime) -} - -// SetAllowStale is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetAllowStale(allowStale bool) { - q.AllowStale = allowStale -} - -// SetRequireConsistent is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetRequireConsistent(requireConsistent bool) { - q.RequireConsistent = requireConsistent -} - -// SetUseCache is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetUseCache(useCache bool) { - q.UseCache = useCache -} - -// SetMaxStaleDuration is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetMaxStaleDuration(maxStaleDuration time.Duration) { - q.MaxStaleDuration = structs.DurationToProtoGogo(maxStaleDuration) -} - -// SetMaxAge is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetMaxAge(maxAge time.Duration) { - q.MaxAge = structs.DurationToProtoGogo(maxAge) -} - -// SetMustRevalidate is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetMustRevalidate(mustRevalidate bool) { - q.MustRevalidate = mustRevalidate -} - -// SetStaleIfError is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetStaleIfError(staleIfError time.Duration) { - q.StaleIfError = structs.DurationToProtoGogo(staleIfError) -} - -func (q QueryOptions) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) { - maxTime := structs.DurationFromProtoGogo(q.MaxQueryTime) - o := structs.QueryOptions{ - MaxQueryTime: maxTime, - MinQueryIndex: q.MinQueryIndex, - } - return o.HasTimedOut(start, rpcHoldTimeout, maxQueryTime, defaultQueryTime) -} - -// SetFilter is needed to implement the structs.QueryOptionsCompat interface -func (q *QueryOptions) SetFilter(filter string) { - q.Filter = filter -} - -// GetMaxQueryTime is required to implement blockingQueryOptions -func (q *QueryOptions) GetMaxQueryTime() (time.Duration, error) { - return structs.DurationFromProtoGogo(q.MaxQueryTime), nil -} - -// GetMinQueryIndex is required to implement blockingQueryOptions -func (q *QueryOptions) GetMinQueryIndex() uint64 { - if q != nil { - return q.MinQueryIndex - } - return 0 -} - -// GetRequireConsistent is required to implement blockingQueryOptions -func (q *QueryOptions) GetRequireConsistent() bool { - if q != nil { - return q.RequireConsistent - } - return false -} - -// GetToken is required to implement blockingQueryOptions -func (q *QueryOptions) GetToken() string { - if q != nil { - return q.Token - } - return "" -} - -// GetAllowStale is required to implement structs.QueryOptionsCompat -func (q *QueryOptions) GetAllowStale() bool { - if q != nil { - return q.AllowStale - } - return false -} - -// GetFilter is required to implement structs.QueryOptionsCompat -func (q *QueryOptions) GetFilter() string { - if q != nil { - return q.Filter - } - return "" -} - -// GetMaxAge is required to implement structs.QueryOptionsCompat -func (q *QueryOptions) GetMaxAge() (time.Duration, error) { - if q != nil { - return structs.DurationFromProtoGogo(q.MaxAge), nil - } - return 0, nil -} - -// GetMaxStaleDuration is required to implement structs.QueryOptionsCompat -func (q *QueryOptions) GetMaxStaleDuration() (time.Duration, error) { - if q != nil { - return structs.DurationFromProtoGogo(q.MaxStaleDuration), nil - } - return 0, nil -} - -// GetMustRevalidate is required to implement structs.QueryOptionsCompat -func (q *QueryOptions) GetMustRevalidate() bool { - if q != nil { - return q.MustRevalidate - } - return false -} - -// GetStaleIfError is required to implement structs.QueryOptionsCompat -func (q *QueryOptions) GetStaleIfError() (time.Duration, error) { - if q != nil { - return structs.DurationFromProtoGogo(q.StaleIfError), nil - } - return 0, nil -} - -// GetUseCache is required to implement structs.QueryOptionsCompat -func (q *QueryOptions) GetUseCache() bool { - if q != nil { - return q.UseCache - } - return false -} - -// SetLastContact is needed to implement the structs.QueryMetaCompat interface -func (q *QueryMeta) SetLastContact(lastContact time.Duration) { - q.LastContact = structs.DurationToProtoGogo(lastContact) -} - -// SetKnownLeader is needed to implement the structs.QueryMetaCompat interface -func (q *QueryMeta) SetKnownLeader(knownLeader bool) { - q.KnownLeader = knownLeader -} - -// SetIndex is needed to implement the structs.QueryMetaCompat interface -func (q *QueryMeta) SetIndex(index uint64) { - q.Index = index -} - -// SetConsistencyLevel is needed to implement the structs.QueryMetaCompat interface -func (q *QueryMeta) SetConsistencyLevel(consistencyLevel string) { - q.ConsistencyLevel = consistencyLevel -} - -func (q *QueryMeta) GetBackend() structs.QueryBackend { - return structs.QueryBackend(0) -} - -// SetResultsFilteredByACLs is needed to implement the structs.QueryMetaCompat interface -func (q *QueryMeta) SetResultsFilteredByACLs(v bool) { - q.ResultsFilteredByACLs = v -} - -// GetIndex is required to implement blockingQueryResponseMeta -func (q *QueryMeta) GetIndex() uint64 { - if q != nil { - return q.Index - } - return 0 -} - -// GetConsistencyLevel is required to implement structs.QueryMetaCompat -func (q *QueryMeta) GetConsistencyLevel() string { - if q != nil { - return q.ConsistencyLevel - } - return "" -} - -// GetKnownLeader is required to implement structs.QueryMetaCompat -func (q *QueryMeta) GetKnownLeader() bool { - if q != nil { - return q.KnownLeader - } - return false -} - -// GetLastContact is required to implement structs.QueryMetaCompat -func (q *QueryMeta) GetLastContact() (time.Duration, error) { - if q != nil { - return structs.DurationFromProtoGogo(q.LastContact), nil - } - return 0, nil -} - -// GetResultsFilteredByACLs is required to implement structs.QueryMetaCompat -func (q *QueryMeta) GetResultsFilteredByACLs() bool { - if q != nil { - return q.ResultsFilteredByACLs - } - return false -} - -// WriteRequest only applies to writes, always false -// -// IsRead implements structs.RPCInfo -func (w WriteRequest) IsRead() bool { - return false -} - -// SetTokenSecret implements structs.RPCInfo -func (w WriteRequest) TokenSecret() string { - return w.Token -} - -// SetTokenSecret implements structs.RPCInfo -func (w *WriteRequest) SetTokenSecret(s string) { - w.Token = s -} - -// AllowStaleRead returns whether a stale read should be allowed -// -// AllowStaleRead implements structs.RPCInfo -func (w WriteRequest) AllowStaleRead() bool { - return false -} - -// HasTimedOut implements structs.RPCInfo -func (w WriteRequest) HasTimedOut(start time.Time, rpcHoldTimeout, _, _ time.Duration) (bool, error) { - return time.Since(start) > rpcHoldTimeout, nil -} - -// IsRead implements structs.RPCInfo -func (r *ReadRequest) IsRead() bool { - return true -} - -// AllowStaleRead implements structs.RPCInfo -func (r *ReadRequest) AllowStaleRead() bool { - // TODO(partitions): plumb this? - return false -} - -// TokenSecret implements structs.RPCInfo -func (r *ReadRequest) TokenSecret() string { - return r.Token -} - -// SetTokenSecret implements structs.RPCInfo -func (r *ReadRequest) SetTokenSecret(token string) { - r.Token = token -} - -// HasTimedOut implements structs.RPCInfo -func (r *ReadRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) { - return time.Since(start) > rpcHoldTimeout, nil -} - -// RequestDatacenter implements structs.RPCInfo -func (td TargetDatacenter) RequestDatacenter() string { - return td.Datacenter -} diff --git a/proto/pbcommongogo/common.pb.binary.go b/proto/pbcommongogo/common.pb.binary.go deleted file mode 100644 index 2e6b574960..0000000000 --- a/proto/pbcommongogo/common.pb.binary.go +++ /dev/null @@ -1,78 +0,0 @@ -// Code generated by protoc-gen-go-binary. DO NOT EDIT. -// source: proto/pbcommongogo/common.proto - -package pbcommongogo - -import ( - "github.com/golang/protobuf/proto" -) - -// MarshalBinary implements encoding.BinaryMarshaler -func (msg *RaftIndex) MarshalBinary() ([]byte, error) { - return proto.Marshal(msg) -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler -func (msg *RaftIndex) UnmarshalBinary(b []byte) error { - return proto.Unmarshal(b, msg) -} - -// MarshalBinary implements encoding.BinaryMarshaler -func (msg *TargetDatacenter) MarshalBinary() ([]byte, error) { - return proto.Marshal(msg) -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler -func (msg *TargetDatacenter) UnmarshalBinary(b []byte) error { - return proto.Unmarshal(b, msg) -} - -// MarshalBinary implements encoding.BinaryMarshaler -func (msg *WriteRequest) MarshalBinary() ([]byte, error) { - return proto.Marshal(msg) -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler -func (msg *WriteRequest) UnmarshalBinary(b []byte) error { - return proto.Unmarshal(b, msg) -} - -// MarshalBinary implements encoding.BinaryMarshaler -func (msg *ReadRequest) MarshalBinary() ([]byte, error) { - return proto.Marshal(msg) -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler -func (msg *ReadRequest) UnmarshalBinary(b []byte) error { - return proto.Unmarshal(b, msg) -} - -// MarshalBinary implements encoding.BinaryMarshaler -func (msg *QueryOptions) MarshalBinary() ([]byte, error) { - return proto.Marshal(msg) -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler -func (msg *QueryOptions) UnmarshalBinary(b []byte) error { - return proto.Unmarshal(b, msg) -} - -// MarshalBinary implements encoding.BinaryMarshaler -func (msg *QueryMeta) MarshalBinary() ([]byte, error) { - return proto.Marshal(msg) -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler -func (msg *QueryMeta) UnmarshalBinary(b []byte) error { - return proto.Unmarshal(b, msg) -} - -// MarshalBinary implements encoding.BinaryMarshaler -func (msg *EnterpriseMeta) MarshalBinary() ([]byte, error) { - return proto.Marshal(msg) -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler -func (msg *EnterpriseMeta) UnmarshalBinary(b []byte) error { - return proto.Unmarshal(b, msg) -} diff --git a/proto/pbcommongogo/common.pb.go b/proto/pbcommongogo/common.pb.go deleted file mode 100644 index 07db0feaac..0000000000 --- a/proto/pbcommongogo/common.pb.go +++ /dev/null @@ -1,2036 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: proto/pbcommongogo/common.proto - -package pbcommongogo - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - types "github.com/gogo/protobuf/types" - proto "github.com/golang/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -// RaftIndex is used to track the index used while creating -// or modifying a given struct type. -// -// mog annotation: -// -// target=github.com/hashicorp/consul/agent/structs.RaftIndex -// output=common.gen.go -// name=Structs -type RaftIndex struct { - CreateIndex uint64 `protobuf:"varint,1,opt,name=CreateIndex,proto3" json:"CreateIndex,omitempty" bexpr:"-"` - ModifyIndex uint64 `protobuf:"varint,2,opt,name=ModifyIndex,proto3" json:"ModifyIndex,omitempty" bexpr:"-"` -} - -func (m *RaftIndex) Reset() { *m = RaftIndex{} } -func (m *RaftIndex) String() string { return proto.CompactTextString(m) } -func (*RaftIndex) ProtoMessage() {} -func (*RaftIndex) Descriptor() ([]byte, []int) { - return fileDescriptor_a834024536145257, []int{0} -} -func (m *RaftIndex) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RaftIndex) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RaftIndex.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RaftIndex) XXX_Merge(src proto.Message) { - xxx_messageInfo_RaftIndex.Merge(m, src) -} -func (m *RaftIndex) XXX_Size() int { - return m.Size() -} -func (m *RaftIndex) XXX_DiscardUnknown() { - xxx_messageInfo_RaftIndex.DiscardUnknown(m) -} - -var xxx_messageInfo_RaftIndex proto.InternalMessageInfo - -// TargetDatacenter is intended to be used within other messages used for RPC routing -// amongst the various Consul datacenters -type TargetDatacenter struct { - Datacenter string `protobuf:"bytes,1,opt,name=Datacenter,proto3" json:"Datacenter,omitempty"` -} - -func (m *TargetDatacenter) Reset() { *m = TargetDatacenter{} } -func (m *TargetDatacenter) String() string { return proto.CompactTextString(m) } -func (*TargetDatacenter) ProtoMessage() {} -func (*TargetDatacenter) Descriptor() ([]byte, []int) { - return fileDescriptor_a834024536145257, []int{1} -} -func (m *TargetDatacenter) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TargetDatacenter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TargetDatacenter.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *TargetDatacenter) XXX_Merge(src proto.Message) { - xxx_messageInfo_TargetDatacenter.Merge(m, src) -} -func (m *TargetDatacenter) XXX_Size() int { - return m.Size() -} -func (m *TargetDatacenter) XXX_DiscardUnknown() { - xxx_messageInfo_TargetDatacenter.DiscardUnknown(m) -} - -var xxx_messageInfo_TargetDatacenter proto.InternalMessageInfo - -type WriteRequest struct { - // Token is the ACL token ID. If not provided, the 'anonymous' - // token is assumed for backwards compatibility. - Token string `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"` -} - -func (m *WriteRequest) Reset() { *m = WriteRequest{} } -func (m *WriteRequest) String() string { return proto.CompactTextString(m) } -func (*WriteRequest) ProtoMessage() {} -func (*WriteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a834024536145257, []int{2} -} -func (m *WriteRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *WriteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_WriteRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *WriteRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_WriteRequest.Merge(m, src) -} -func (m *WriteRequest) XXX_Size() int { - return m.Size() -} -func (m *WriteRequest) XXX_DiscardUnknown() { - xxx_messageInfo_WriteRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_WriteRequest proto.InternalMessageInfo - -// ReadRequest is a type that may be embedded into any requests for read -// operations. -// It is a replacement for QueryOptions now that we no longer need any of those -// fields because we are moving away from using blocking queries. -// It is also similar to WriteRequest. It is a separate type so that in the -// future we can introduce fields that may only be relevant for reads. -type ReadRequest struct { - // Token is the ACL token ID. If not provided, the 'anonymous' - // token is assumed for backwards compatibility. - Token string `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"` - // RequireConsistent indicates that the request must be sent to the leader. - RequireConsistent bool `protobuf:"varint,2,opt,name=RequireConsistent,proto3" json:"RequireConsistent,omitempty"` -} - -func (m *ReadRequest) Reset() { *m = ReadRequest{} } -func (m *ReadRequest) String() string { return proto.CompactTextString(m) } -func (*ReadRequest) ProtoMessage() {} -func (*ReadRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a834024536145257, []int{3} -} -func (m *ReadRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ReadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ReadRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ReadRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReadRequest.Merge(m, src) -} -func (m *ReadRequest) XXX_Size() int { - return m.Size() -} -func (m *ReadRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ReadRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ReadRequest proto.InternalMessageInfo - -// QueryOptions is used to specify various flags for read queries -// -// mog annotation: -// -// target=github.com/hashicorp/consul/agent/structs.QueryOptions -// output=common.gen.go -// name=Structs -// ignore-fields=StaleIfError,AllowNotModifiedResponse -type QueryOptions struct { - // Token is the ACL token ID. If not provided, the 'anonymous' - // token is assumed for backwards compatibility. - Token string `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"` - // If set, wait until query exceeds given index. Must be provided - // with MaxQueryTime. - MinQueryIndex uint64 `protobuf:"varint,2,opt,name=MinQueryIndex,proto3" json:"MinQueryIndex,omitempty"` - // Provided with MinQueryIndex to wait for change. - // mog: func-to=structs.DurationFromProtoGogo func-from=structs.DurationToProtoGogo - MaxQueryTime types.Duration `protobuf:"bytes,3,opt,name=MaxQueryTime,proto3" json:"MaxQueryTime"` - // If set, any follower can service the request. Results - // may be arbitrarily stale. - AllowStale bool `protobuf:"varint,4,opt,name=AllowStale,proto3" json:"AllowStale,omitempty"` - // If set, the leader must verify leadership prior to - // servicing the request. Prevents a stale read. - RequireConsistent bool `protobuf:"varint,5,opt,name=RequireConsistent,proto3" json:"RequireConsistent,omitempty"` - // If set, the local agent may respond with an arbitrarily stale locally - // cached response. The semantics differ from AllowStale since the agent may - // be entirely partitioned from the servers and still considered "healthy" by - // operators. Stale responses from Servers are also arbitrarily stale, but can - // provide additional bounds on the last contact time from the leader. It's - // expected that servers that are partitioned are noticed and replaced in a - // timely way by operators while the same may not be true for client agents. - UseCache bool `protobuf:"varint,6,opt,name=UseCache,proto3" json:"UseCache,omitempty"` - // If set and AllowStale is true, will try first a stale - // read, and then will perform a consistent read if stale - // read is older than value. - // mog: func-to=structs.DurationFromProtoGogo func-from=structs.DurationToProtoGogo - MaxStaleDuration types.Duration `protobuf:"bytes,7,opt,name=MaxStaleDuration,proto3" json:"MaxStaleDuration"` - // MaxAge limits how old a cached value will be returned if UseCache is true. - // If there is a cached response that is older than the MaxAge, it is treated - // as a cache miss and a new fetch invoked. If the fetch fails, the error is - // returned. Clients that wish to allow for stale results on error can set - // StaleIfError to a longer duration to change this behavior. It is ignored - // if the endpoint supports background refresh caching. See - // https://www.consul.io/api/index.html#agent-caching for more details. - // mog: func-to=structs.DurationFromProtoGogo func-from=structs.DurationToProtoGogo - MaxAge types.Duration `protobuf:"bytes,8,opt,name=MaxAge,proto3" json:"MaxAge"` - // MustRevalidate forces the agent to fetch a fresh version of a cached - // resource or at least validate that the cached version is still fresh. It is - // implied by either max-age=0 or must-revalidate Cache-Control headers. It - // only makes sense when UseCache is true. We store it since MaxAge = 0 is the - // default unset value. - MustRevalidate bool `protobuf:"varint,9,opt,name=MustRevalidate,proto3" json:"MustRevalidate,omitempty"` - // StaleIfError specifies how stale the client will accept a cached response - // if the servers are unavailable to fetch a fresh one. Only makes sense when - // UseCache is true and MaxAge is set to a lower, non-zero value. It is - // ignored if the endpoint supports background refresh caching. See - // https://www.consul.io/api/index.html#agent-caching for more details. - StaleIfError types.Duration `protobuf:"bytes,10,opt,name=StaleIfError,proto3" json:"StaleIfError"` - // Filter specifies the go-bexpr filter expression to be used for - // filtering the data prior to returning a response - Filter string `protobuf:"bytes,11,opt,name=Filter,proto3" json:"Filter,omitempty"` -} - -func (m *QueryOptions) Reset() { *m = QueryOptions{} } -func (m *QueryOptions) String() string { return proto.CompactTextString(m) } -func (*QueryOptions) ProtoMessage() {} -func (*QueryOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_a834024536145257, []int{4} -} -func (m *QueryOptions) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryOptions.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryOptions) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOptions.Merge(m, src) -} -func (m *QueryOptions) XXX_Size() int { - return m.Size() -} -func (m *QueryOptions) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOptions.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryOptions proto.InternalMessageInfo - -// QueryMeta allows a query response to include potentially -// useful metadata about a query -// -// mog annotation: -// -// target=github.com/hashicorp/consul/agent/structs.QueryMeta -// output=common.gen.go -// name=Structs -// ignore-fields=NotModified,Backend -type QueryMeta struct { - // This is the index associated with the read - Index uint64 `protobuf:"varint,1,opt,name=Index,proto3" json:"Index,omitempty"` - // If AllowStale is used, this is time elapsed since - // last contact between the follower and leader. This - // can be used to gauge staleness. - // mog: func-to=structs.DurationFromProtoGogo func-from=structs.DurationToProtoGogo - LastContact types.Duration `protobuf:"bytes,2,opt,name=LastContact,proto3" json:"LastContact"` - // Used to indicate if there is a known leader node - KnownLeader bool `protobuf:"varint,3,opt,name=KnownLeader,proto3" json:"KnownLeader,omitempty"` - // Consistencylevel returns the consistency used to serve the query - // Having `discovery_max_stale` on the agent can affect whether - // the request was served by a leader. - ConsistencyLevel string `protobuf:"bytes,4,opt,name=ConsistencyLevel,proto3" json:"ConsistencyLevel,omitempty"` - // ResultsFilteredByACLs is true when some of the query's results were - // filtered out by enforcing ACLs. It may be false because nothing was - // removed, or because the endpoint does not yet support this flag. - ResultsFilteredByACLs bool `protobuf:"varint,7,opt,name=ResultsFilteredByACLs,proto3" json:"ResultsFilteredByACLs,omitempty"` -} - -func (m *QueryMeta) Reset() { *m = QueryMeta{} } -func (m *QueryMeta) String() string { return proto.CompactTextString(m) } -func (*QueryMeta) ProtoMessage() {} -func (*QueryMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_a834024536145257, []int{5} -} -func (m *QueryMeta) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryMeta.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryMeta) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryMeta.Merge(m, src) -} -func (m *QueryMeta) XXX_Size() int { - return m.Size() -} -func (m *QueryMeta) XXX_DiscardUnknown() { - xxx_messageInfo_QueryMeta.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryMeta proto.InternalMessageInfo - -// EnterpriseMeta contains metadata that is only used by the Enterprise version -// of Consul. -type EnterpriseMeta struct { - // Namespace in which the entity exists. - Namespace string `protobuf:"bytes,1,opt,name=Namespace,proto3" json:"Namespace,omitempty"` - // Partition in which the entity exists. - Partition string `protobuf:"bytes,2,opt,name=Partition,proto3" json:"Partition,omitempty"` -} - -func (m *EnterpriseMeta) Reset() { *m = EnterpriseMeta{} } -func (m *EnterpriseMeta) String() string { return proto.CompactTextString(m) } -func (*EnterpriseMeta) ProtoMessage() {} -func (*EnterpriseMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_a834024536145257, []int{6} -} -func (m *EnterpriseMeta) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EnterpriseMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EnterpriseMeta.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EnterpriseMeta) XXX_Merge(src proto.Message) { - xxx_messageInfo_EnterpriseMeta.Merge(m, src) -} -func (m *EnterpriseMeta) XXX_Size() int { - return m.Size() -} -func (m *EnterpriseMeta) XXX_DiscardUnknown() { - xxx_messageInfo_EnterpriseMeta.DiscardUnknown(m) -} - -var xxx_messageInfo_EnterpriseMeta proto.InternalMessageInfo - -func init() { - proto.RegisterType((*RaftIndex)(nil), "commongogo.RaftIndex") - proto.RegisterType((*TargetDatacenter)(nil), "commongogo.TargetDatacenter") - proto.RegisterType((*WriteRequest)(nil), "commongogo.WriteRequest") - proto.RegisterType((*ReadRequest)(nil), "commongogo.ReadRequest") - proto.RegisterType((*QueryOptions)(nil), "commongogo.QueryOptions") - proto.RegisterType((*QueryMeta)(nil), "commongogo.QueryMeta") - proto.RegisterType((*EnterpriseMeta)(nil), "commongogo.EnterpriseMeta") -} - -func init() { proto.RegisterFile("proto/pbcommongogo/common.proto", fileDescriptor_a834024536145257) } - -var fileDescriptor_a834024536145257 = []byte{ - // 639 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x4d, 0x4a, 0x9a, 0x26, 0x93, 0xb6, 0x0a, 0xab, 0x82, 0x4c, 0x85, 0xdc, 0xca, 0xaa, 0x50, - 0x85, 0x20, 0x96, 0x0a, 0x12, 0x12, 0xb7, 0x24, 0x2d, 0x52, 0xdb, 0x18, 0xda, 0xa5, 0x08, 0x89, - 0xdb, 0xc6, 0x9e, 0x38, 0x16, 0x8e, 0xd7, 0xec, 0xae, 0xdb, 0xe4, 0xce, 0x07, 0x70, 0xe4, 0x93, - 0x7a, 0xec, 0x91, 0x53, 0x05, 0xcd, 0x1f, 0x20, 0x3e, 0x00, 0x79, 0x9d, 0xb6, 0x2e, 0x69, 0x51, - 0x6e, 0x9e, 0x37, 0xef, 0xed, 0xce, 0xcc, 0x9b, 0x35, 0xac, 0xc5, 0x82, 0x2b, 0x6e, 0xc7, 0x5d, - 0x97, 0x0f, 0x06, 0x3c, 0xf2, 0xb9, 0xcf, 0xed, 0xec, 0xb3, 0xa1, 0x33, 0x04, 0xae, 0x13, 0xab, - 0xa6, 0xcf, 0xb9, 0x1f, 0xa2, 0xad, 0x33, 0xdd, 0xa4, 0x67, 0x7b, 0x89, 0x60, 0x2a, 0xb8, 0xe4, - 0xae, 0xae, 0xa4, 0xac, 0xec, 0xc0, 0xf4, 0x2b, 0x43, 0xad, 0x01, 0x54, 0x29, 0xeb, 0xa9, 0xdd, - 0xc8, 0xc3, 0x21, 0xb1, 0xa1, 0xd6, 0x16, 0xc8, 0x14, 0xea, 0xd0, 0x28, 0xae, 0x17, 0x37, 0x4b, - 0xad, 0xa5, 0xdf, 0xe7, 0x6b, 0xd5, 0x2e, 0x0e, 0x63, 0xf1, 0xda, 0x7a, 0x6e, 0xd1, 0x3c, 0x23, - 0x15, 0x38, 0xdc, 0x0b, 0x7a, 0xa3, 0x4c, 0x30, 0x77, 0xab, 0x20, 0xc7, 0xb0, 0xb6, 0xa0, 0x7e, - 0xc4, 0x84, 0x8f, 0x6a, 0x9b, 0x29, 0xe6, 0x62, 0xa4, 0x50, 0x10, 0x13, 0xe0, 0x3a, 0xd2, 0x97, - 0x56, 0x69, 0x0e, 0xb1, 0x36, 0x60, 0xf1, 0xa3, 0x08, 0x14, 0x52, 0xfc, 0x92, 0xa0, 0x54, 0x64, - 0x05, 0xe6, 0x8f, 0xf8, 0x67, 0x8c, 0x26, 0xd4, 0x2c, 0xb0, 0x0e, 0xa1, 0x46, 0x91, 0x79, 0xff, - 0x25, 0x91, 0x67, 0x70, 0x3f, 0x25, 0x04, 0x02, 0xdb, 0x3c, 0x92, 0x81, 0x54, 0x18, 0x29, 0x5d, - 0x75, 0x85, 0x4e, 0x27, 0xac, 0xaf, 0x25, 0x58, 0x3c, 0x4c, 0x50, 0x8c, 0xde, 0xc5, 0xe9, 0x1c, - 0xe5, 0x1d, 0x87, 0x6e, 0xc0, 0x92, 0x13, 0x44, 0x9a, 0x98, 0x1b, 0x03, 0xbd, 0x09, 0x92, 0x36, - 0x2c, 0x3a, 0x6c, 0xa8, 0x81, 0xa3, 0x60, 0x80, 0xc6, 0xbd, 0xf5, 0xe2, 0x66, 0x6d, 0xeb, 0x51, - 0x23, 0x73, 0xad, 0x71, 0xe9, 0x5a, 0x63, 0x7b, 0xe2, 0x5a, 0xab, 0x74, 0x7a, 0xbe, 0x56, 0xa0, - 0x37, 0x44, 0xe9, 0xa8, 0x9a, 0x61, 0xc8, 0x4f, 0xde, 0x2b, 0x16, 0xa2, 0x51, 0xd2, 0x85, 0xe7, - 0x90, 0xdb, 0xfb, 0x9b, 0xbf, 0xa3, 0x3f, 0xb2, 0x0a, 0x95, 0x0f, 0x12, 0xdb, 0xcc, 0xed, 0xa3, - 0x51, 0xd6, 0xa4, 0xab, 0x98, 0xec, 0x43, 0xdd, 0x61, 0x43, 0x7d, 0xea, 0x65, 0x45, 0xc6, 0xc2, - 0x6c, 0x25, 0x4f, 0x09, 0xc9, 0x2b, 0x28, 0x3b, 0x6c, 0xd8, 0xf4, 0xd1, 0xa8, 0xcc, 0x76, 0xc4, - 0x84, 0x4e, 0x9e, 0xc0, 0xb2, 0x93, 0x48, 0x45, 0xf1, 0x98, 0x85, 0x81, 0xc7, 0x14, 0x1a, 0x55, - 0x5d, 0xe7, 0x3f, 0x68, 0x3a, 0x5c, 0x7d, 0xe3, 0x6e, 0x6f, 0x47, 0x08, 0x2e, 0x0c, 0x98, 0x71, - 0xb8, 0x79, 0x11, 0x79, 0x08, 0xe5, 0x37, 0x41, 0x98, 0xee, 0x60, 0x4d, 0xdb, 0x3b, 0x89, 0xac, - 0x3f, 0x45, 0xa8, 0x6a, 0x0b, 0x1c, 0x54, 0x2c, 0xdd, 0x81, 0xdc, 0xeb, 0xa0, 0x59, 0x40, 0x9a, - 0x50, 0xeb, 0x30, 0xa9, 0xda, 0x3c, 0x52, 0xcc, 0xcd, 0x56, 0x6a, 0x86, 0xfb, 0xf3, 0x1a, 0xb2, - 0x0e, 0xb5, 0xfd, 0x88, 0x9f, 0x44, 0x1d, 0x64, 0x1e, 0x0a, 0xbd, 0x1f, 0x15, 0x9a, 0x87, 0xc8, - 0x53, 0xa8, 0x5f, 0xb9, 0xe7, 0x8e, 0x3a, 0x78, 0x8c, 0xa1, 0xde, 0x81, 0x2a, 0x9d, 0xc2, 0xc9, - 0x4b, 0x78, 0x40, 0x51, 0x26, 0xa1, 0x92, 0x59, 0x17, 0xe8, 0xb5, 0x46, 0xcd, 0x76, 0x47, 0x6a, - 0x13, 0x2b, 0xf4, 0xf6, 0xe4, 0x5e, 0xa9, 0x32, 0x5f, 0x2f, 0xef, 0x95, 0x2a, 0xe5, 0xfa, 0x82, - 0xd5, 0x81, 0xe5, 0x9d, 0xf4, 0xfd, 0xc5, 0x22, 0x90, 0xa8, 0x5b, 0x7f, 0x0c, 0xd5, 0xb7, 0x6c, - 0x80, 0x32, 0x66, 0x2e, 0x4e, 0x9e, 0xc0, 0x35, 0x90, 0x66, 0x0f, 0x98, 0x50, 0x81, 0x5e, 0x95, - 0xb9, 0x2c, 0x7b, 0x05, 0xb4, 0x0e, 0x4e, 0x7f, 0x99, 0x85, 0xd3, 0x0b, 0xb3, 0x78, 0x76, 0x61, - 0x16, 0x7f, 0x5e, 0x98, 0xc5, 0x6f, 0x63, 0xb3, 0xf0, 0x7d, 0x6c, 0x16, 0xce, 0xc6, 0x66, 0xe1, - 0xc7, 0xd8, 0x2c, 0x7c, 0x6a, 0xf8, 0x81, 0xea, 0x27, 0xdd, 0x86, 0xcb, 0x07, 0x76, 0x9f, 0xc9, - 0x7e, 0xe0, 0x72, 0x11, 0xdb, 0x2e, 0x8f, 0x64, 0x12, 0xda, 0xd3, 0x3f, 0xc2, 0x6e, 0x59, 0x63, - 0x2f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x17, 0x8b, 0xc5, 0x82, 0x25, 0x05, 0x00, 0x00, -} - -func (m *RaftIndex) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RaftIndex) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RaftIndex) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ModifyIndex != 0 { - i = encodeVarintCommon(dAtA, i, uint64(m.ModifyIndex)) - i-- - dAtA[i] = 0x10 - } - if m.CreateIndex != 0 { - i = encodeVarintCommon(dAtA, i, uint64(m.CreateIndex)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *TargetDatacenter) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *TargetDatacenter) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TargetDatacenter) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Datacenter) > 0 { - i -= len(m.Datacenter) - copy(dAtA[i:], m.Datacenter) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Datacenter))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *WriteRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *WriteRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *WriteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Token) > 0 { - i -= len(m.Token) - copy(dAtA[i:], m.Token) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Token))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ReadRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ReadRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ReadRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.RequireConsistent { - i-- - if m.RequireConsistent { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - if len(m.Token) > 0 { - i -= len(m.Token) - copy(dAtA[i:], m.Token) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Token))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryOptions) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryOptions) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Filter) > 0 { - i -= len(m.Filter) - copy(dAtA[i:], m.Filter) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Filter))) - i-- - dAtA[i] = 0x5a - } - { - size, err := m.StaleIfError.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - if m.MustRevalidate { - i-- - if m.MustRevalidate { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x48 - } - { - size, err := m.MaxAge.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - { - size, err := m.MaxStaleDuration.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - if m.UseCache { - i-- - if m.UseCache { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x30 - } - if m.RequireConsistent { - i-- - if m.RequireConsistent { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x28 - } - if m.AllowStale { - i-- - if m.AllowStale { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } - { - size, err := m.MaxQueryTime.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.MinQueryIndex != 0 { - i = encodeVarintCommon(dAtA, i, uint64(m.MinQueryIndex)) - i-- - dAtA[i] = 0x10 - } - if len(m.Token) > 0 { - i -= len(m.Token) - copy(dAtA[i:], m.Token) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Token))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryMeta) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryMeta) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ResultsFilteredByACLs { - i-- - if m.ResultsFilteredByACLs { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x38 - } - if len(m.ConsistencyLevel) > 0 { - i -= len(m.ConsistencyLevel) - copy(dAtA[i:], m.ConsistencyLevel) - i = encodeVarintCommon(dAtA, i, uint64(len(m.ConsistencyLevel))) - i-- - dAtA[i] = 0x22 - } - if m.KnownLeader { - i-- - if m.KnownLeader { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x18 - } - { - size, err := m.LastContact.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.Index != 0 { - i = encodeVarintCommon(dAtA, i, uint64(m.Index)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *EnterpriseMeta) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EnterpriseMeta) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EnterpriseMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Partition) > 0 { - i -= len(m.Partition) - copy(dAtA[i:], m.Partition) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Partition))) - i-- - dAtA[i] = 0x12 - } - if len(m.Namespace) > 0 { - i -= len(m.Namespace) - copy(dAtA[i:], m.Namespace) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Namespace))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintCommon(dAtA []byte, offset int, v uint64) int { - offset -= sovCommon(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *RaftIndex) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CreateIndex != 0 { - n += 1 + sovCommon(uint64(m.CreateIndex)) - } - if m.ModifyIndex != 0 { - n += 1 + sovCommon(uint64(m.ModifyIndex)) - } - return n -} - -func (m *TargetDatacenter) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Datacenter) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - return n -} - -func (m *WriteRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Token) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - return n -} - -func (m *ReadRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Token) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - if m.RequireConsistent { - n += 2 - } - return n -} - -func (m *QueryOptions) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Token) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - if m.MinQueryIndex != 0 { - n += 1 + sovCommon(uint64(m.MinQueryIndex)) - } - l = m.MaxQueryTime.Size() - n += 1 + l + sovCommon(uint64(l)) - if m.AllowStale { - n += 2 - } - if m.RequireConsistent { - n += 2 - } - if m.UseCache { - n += 2 - } - l = m.MaxStaleDuration.Size() - n += 1 + l + sovCommon(uint64(l)) - l = m.MaxAge.Size() - n += 1 + l + sovCommon(uint64(l)) - if m.MustRevalidate { - n += 2 - } - l = m.StaleIfError.Size() - n += 1 + l + sovCommon(uint64(l)) - l = len(m.Filter) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - return n -} - -func (m *QueryMeta) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Index != 0 { - n += 1 + sovCommon(uint64(m.Index)) - } - l = m.LastContact.Size() - n += 1 + l + sovCommon(uint64(l)) - if m.KnownLeader { - n += 2 - } - l = len(m.ConsistencyLevel) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - if m.ResultsFilteredByACLs { - n += 2 - } - return n -} - -func (m *EnterpriseMeta) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Namespace) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - l = len(m.Partition) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - return n -} - -func sovCommon(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozCommon(x uint64) (n int) { - return sovCommon(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *RaftIndex) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RaftIndex: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RaftIndex: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CreateIndex", wireType) - } - m.CreateIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CreateIndex |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ModifyIndex", wireType) - } - m.ModifyIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ModifyIndex |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TargetDatacenter) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: TargetDatacenter: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TargetDatacenter: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Datacenter", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Datacenter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *WriteRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: WriteRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: WriteRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Token = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ReadRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ReadRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ReadRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Token = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RequireConsistent", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.RequireConsistent = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryOptions) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryOptions: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOptions: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Token = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinQueryIndex", wireType) - } - m.MinQueryIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinQueryIndex |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxQueryTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxQueryTime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AllowStale", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AllowStale = bool(v != 0) - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RequireConsistent", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.RequireConsistent = bool(v != 0) - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UseCache", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.UseCache = bool(v != 0) - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxStaleDuration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxStaleDuration.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxAge", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxAge.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MustRevalidate", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.MustRevalidate = bool(v != 0) - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StaleIfError", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.StaleIfError.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Filter", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Filter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryMeta) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryMeta: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryMeta: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - m.Index = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Index |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastContact", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LastContact.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field KnownLeader", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.KnownLeader = bool(v != 0) - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsistencyLevel", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsistencyLevel = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ResultsFilteredByACLs", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ResultsFilteredByACLs = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EnterpriseMeta) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EnterpriseMeta: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EnterpriseMeta: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Namespace = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Partition", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Partition = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipCommon(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommon - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommon - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommon - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthCommon - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupCommon - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthCommon - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthCommon = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowCommon = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupCommon = fmt.Errorf("proto: unexpected end of group") -) diff --git a/proto/pbcommongogo/common.proto b/proto/pbcommongogo/common.proto deleted file mode 100644 index 30cd847f33..0000000000 --- a/proto/pbcommongogo/common.proto +++ /dev/null @@ -1,182 +0,0 @@ -syntax = "proto3"; - -package commongogo; - -option go_package = "github.com/hashicorp/consul/proto/pbcommongogo"; - -import "google/protobuf/duration.proto"; -// Go Modules now includes the version in the filepath for packages within GOPATH/pkg/mode -// Therefore unless we want to hardcode a version here like -// github.com/gogo/protobuf@v1.3.0/gogoproto/gogo.proto then the only other choice is to -// have a more relative import and pass the right import path to protoc. I don't like it -// but its necessary. -import "gogoproto/gogo.proto"; - -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_getters_all) = false; -option (gogoproto.goproto_sizecache_all) = false; - -// RaftIndex is used to track the index used while creating -// or modifying a given struct type. -// -// mog annotation: -// -// target=github.com/hashicorp/consul/agent/structs.RaftIndex -// output=common.gen.go -// name=Structs -message RaftIndex { - uint64 CreateIndex = 1 [(gogoproto.moretags) = "bexpr:\"-\""]; - uint64 ModifyIndex = 2 [(gogoproto.moretags) = "bexpr:\"-\""]; -} - -// TargetDatacenter is intended to be used within other messages used for RPC routing -// amongst the various Consul datacenters -message TargetDatacenter { - string Datacenter = 1; -} - -message WriteRequest { - // Token is the ACL token ID. If not provided, the 'anonymous' - // token is assumed for backwards compatibility. - string Token = 1; -} - -// ReadRequest is a type that may be embedded into any requests for read -// operations. -// It is a replacement for QueryOptions now that we no longer need any of those -// fields because we are moving away from using blocking queries. -// It is also similar to WriteRequest. It is a separate type so that in the -// future we can introduce fields that may only be relevant for reads. -message ReadRequest { - // Token is the ACL token ID. If not provided, the 'anonymous' - // token is assumed for backwards compatibility. - string Token = 1; - - // RequireConsistent indicates that the request must be sent to the leader. - bool RequireConsistent = 2; -} - - -// QueryOptions is used to specify various flags for read queries -// -// mog annotation: -// -// target=github.com/hashicorp/consul/agent/structs.QueryOptions -// output=common.gen.go -// name=Structs -// ignore-fields=StaleIfError,AllowNotModifiedResponse -message QueryOptions { - // Token is the ACL token ID. If not provided, the 'anonymous' - // token is assumed for backwards compatibility. - string Token = 1; - - // If set, wait until query exceeds given index. Must be provided - // with MaxQueryTime. - uint64 MinQueryIndex = 2; - - // Provided with MinQueryIndex to wait for change. - // mog: func-to=structs.DurationFromProtoGogo func-from=structs.DurationToProtoGogo - google.protobuf.Duration MaxQueryTime = 3 - [(gogoproto.nullable) = false]; - - // If set, any follower can service the request. Results - // may be arbitrarily stale. - bool AllowStale = 4; - - // If set, the leader must verify leadership prior to - // servicing the request. Prevents a stale read. - bool RequireConsistent = 5; - - // If set, the local agent may respond with an arbitrarily stale locally - // cached response. The semantics differ from AllowStale since the agent may - // be entirely partitioned from the servers and still considered "healthy" by - // operators. Stale responses from Servers are also arbitrarily stale, but can - // provide additional bounds on the last contact time from the leader. It's - // expected that servers that are partitioned are noticed and replaced in a - // timely way by operators while the same may not be true for client agents. - bool UseCache = 6; - - // If set and AllowStale is true, will try first a stale - // read, and then will perform a consistent read if stale - // read is older than value. - // mog: func-to=structs.DurationFromProtoGogo func-from=structs.DurationToProtoGogo - google.protobuf.Duration MaxStaleDuration = 7 - [(gogoproto.nullable) = false]; - - // MaxAge limits how old a cached value will be returned if UseCache is true. - // If there is a cached response that is older than the MaxAge, it is treated - // as a cache miss and a new fetch invoked. If the fetch fails, the error is - // returned. Clients that wish to allow for stale results on error can set - // StaleIfError to a longer duration to change this behavior. It is ignored - // if the endpoint supports background refresh caching. See - // https://www.consul.io/api/index.html#agent-caching for more details. - // mog: func-to=structs.DurationFromProtoGogo func-from=structs.DurationToProtoGogo - google.protobuf.Duration MaxAge = 8 - [(gogoproto.nullable) = false]; - - // MustRevalidate forces the agent to fetch a fresh version of a cached - // resource or at least validate that the cached version is still fresh. It is - // implied by either max-age=0 or must-revalidate Cache-Control headers. It - // only makes sense when UseCache is true. We store it since MaxAge = 0 is the - // default unset value. - bool MustRevalidate = 9; - - // StaleIfError specifies how stale the client will accept a cached response - // if the servers are unavailable to fetch a fresh one. Only makes sense when - // UseCache is true and MaxAge is set to a lower, non-zero value. It is - // ignored if the endpoint supports background refresh caching. See - // https://www.consul.io/api/index.html#agent-caching for more details. - google.protobuf.Duration StaleIfError = 10 - [(gogoproto.nullable) = false]; - - // Filter specifies the go-bexpr filter expression to be used for - // filtering the data prior to returning a response - string Filter = 11; -} - -// QueryMeta allows a query response to include potentially -// useful metadata about a query -// -// mog annotation: -// -// target=github.com/hashicorp/consul/agent/structs.QueryMeta -// output=common.gen.go -// name=Structs -// ignore-fields=NotModified,Backend -message QueryMeta { - // This is the index associated with the read - uint64 Index = 1; - - // If AllowStale is used, this is time elapsed since - // last contact between the follower and leader. This - // can be used to gauge staleness. - // mog: func-to=structs.DurationFromProtoGogo func-from=structs.DurationToProtoGogo - google.protobuf.Duration LastContact = 2 - [(gogoproto.nullable) = false]; - - // Used to indicate if there is a known leader node - bool KnownLeader = 3; - - // Consistencylevel returns the consistency used to serve the query - // Having `discovery_max_stale` on the agent can affect whether - // the request was served by a leader. - string ConsistencyLevel = 4; - - // Reserved for NotModified and Backend. - reserved 5, 6; - - // ResultsFilteredByACLs is true when some of the query's results were - // filtered out by enforcing ACLs. It may be false because nothing was - // removed, or because the endpoint does not yet support this flag. - bool ResultsFilteredByACLs = 7; -} - -// EnterpriseMeta contains metadata that is only used by the Enterprise version -// of Consul. -message EnterpriseMeta { - // Namespace in which the entity exists. - string Namespace = 1; - // Partition in which the entity exists. - string Partition = 2; -} diff --git a/proto/pbcommongogo/common_oss.go b/proto/pbcommongogo/common_oss.go deleted file mode 100644 index d24b27b69c..0000000000 --- a/proto/pbcommongogo/common_oss.go +++ /dev/null @@ -1,25 +0,0 @@ -//go:build !consulent -// +build !consulent - -package pbcommongogo - -import ( - "github.com/hashicorp/consul/agent/structs" -) - -var DefaultEnterpriseMeta = EnterpriseMeta{} - -func NewEnterpriseMetaFromStructs(_ structs.EnterpriseMeta) *EnterpriseMeta { - return &EnterpriseMeta{} -} - -func EnterpriseMetaToStructs(s *EnterpriseMeta, t *structs.EnterpriseMeta) { - if s == nil { - return - } -} -func EnterpriseMetaFromStructs(t *structs.EnterpriseMeta, s *EnterpriseMeta) { - if s == nil { - return - } -} diff --git a/proto/pbservice/convert_pbstruct.go b/proto/pbservice/convert_pbstruct.go index 1a09d81efc..8b1902942d 100644 --- a/proto/pbservice/convert_pbstruct.go +++ b/proto/pbservice/convert_pbstruct.go @@ -4,7 +4,6 @@ import ( fmt "fmt" "reflect" - //TODO(gogo-remove): remove the types alias types "github.com/golang/protobuf/ptypes/struct" ) diff --git a/proto/pbutil/pbutil.go b/proto/pbutil/pbutil.go deleted file mode 100644 index 91736c0614..0000000000 --- a/proto/pbutil/pbutil.go +++ /dev/null @@ -1,23 +0,0 @@ -package pbutil - -import ( - "time" - - "github.com/gogo/protobuf/types" -) - -func DurationToProto(d time.Duration) *types.Duration { - return types.DurationProto(d) -} - -func DurationFromProto(d *types.Duration) (time.Duration, error) { - return types.DurationFromProto(d) -} - -func TimeFromProto(s *types.Timestamp) (time.Time, error) { - return types.TimestampFromProto(s) -} - -func TimeToProto(s time.Time) (*types.Timestamp, error) { - return types.TimestampProto(s) -} diff --git a/proto/translate.go b/proto/translate.go deleted file mode 100644 index 6ee90c084d..0000000000 --- a/proto/translate.go +++ /dev/null @@ -1,68 +0,0 @@ -package proto - -import ( - "reflect" - "time" - - "github.com/gogo/protobuf/types" -) - -var ( - tsType = reflect.TypeOf((*types.Timestamp)(nil)) - timePtrType = reflect.TypeOf((*time.Time)(nil)) - timeType = timePtrType.Elem() - mapStrInf = reflect.TypeOf((map[string]interface{})(nil)) - - epoch1970 = time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC) -) - -// HookPBTimestampToTime is a mapstructure decode hook to translate a protobuf timestamp -// to a time.Time value -func HookPBTimestampToTime(from, to reflect.Type, data interface{}) (interface{}, error) { - if to == timeType && from == tsType { - ts := data.(*types.Timestamp) - if ts.Seconds == 0 && ts.Nanos == 0 { - return time.Time{}, nil - } - return time.Unix(ts.Seconds, int64(ts.Nanos)).UTC(), nil - } - - return data, nil -} - -// HookTimeToPBtimestamp is a mapstructure decode hook to translate a time.Time value to -// a protobuf Timestamp value. -func HookTimeToPBTimestamp(from, to reflect.Type, data interface{}) (interface{}, error) { - // Note that mapstructure doesn't do direct struct to struct conversion in this case. I - // still don't completely understand why converting the PB TS to time.Time does but - // I suspect it has something to do with the struct containing a concrete time.Time - // as opposed to a pointer to a time.Time. Regardless this path through mapstructure - // first will decode the concrete time.Time into a map[string]interface{} before - // eventually decoding that map[string]interface{} into the *types.Timestamp. One - // other note is that mapstructure ends up creating a new Value and sets it it to - // the time.Time value and thats what gets passed to us. That is why we end up - // seeing a *time.Time instead of a time.Time. - if from == timePtrType && to == mapStrInf { - ts := data.(*time.Time) - - // protobuf only supports times from Jan 1 1970 onward but the time.Time type - // can represent values back to year 1. Basically - if ts.Before(epoch1970) { - return map[string]interface{}{}, nil - } - - nanos := ts.UnixNano() - if nanos < 0 { - return map[string]interface{}{}, nil - } - - seconds := nanos / 1000000000 - nanos = nanos % 1000000000 - - return map[string]interface{}{ - "Seconds": seconds, - "Nanos": int32(nanos), - }, nil - } - return data, nil -} diff --git a/proto/translate_test.go b/proto/translate_test.go deleted file mode 100644 index 0fbfa2b9b8..0000000000 --- a/proto/translate_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package proto - -import ( - "testing" - "time" - - "github.com/gogo/protobuf/types" - "github.com/mitchellh/mapstructure" - - "github.com/stretchr/testify/require" -) - -type pbTSWrapper struct { - Timestamp *types.Timestamp -} - -type timeTSWrapper struct { - Timestamp time.Time -} - -func TestHookPBTimestampToTime(t *testing.T) { - in := pbTSWrapper{ - Timestamp: &types.Timestamp{ - Seconds: 1000, - Nanos: 42, - }, - } - - expected := timeTSWrapper{ - Timestamp: time.Unix(1000, 42).UTC(), - } - - var actual timeTSWrapper - decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ - DecodeHook: HookPBTimestampToTime, - Result: &actual, - }) - require.NoError(t, err) - require.NoError(t, decoder.Decode(in)) - - require.Equal(t, expected, actual) -} - -func TestHookTimeToPBTimestamp(t *testing.T) { - in := timeTSWrapper{ - Timestamp: time.Unix(999999, 123456).UTC(), - } - - expected := pbTSWrapper{ - Timestamp: &types.Timestamp{ - Seconds: 999999, - Nanos: 123456, - }, - } - - var actual pbTSWrapper - decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ - DecodeHook: HookTimeToPBTimestamp, - Result: &actual, - }) - require.NoError(t, err) - require.NoError(t, decoder.Decode(in)) - - require.Equal(t, expected, actual) -} - -func TestHookTimeToPBTimestamp_ZeroTime(t *testing.T) { - in := timeTSWrapper{} - - expected := pbTSWrapper{ - Timestamp: &types.Timestamp{ - Seconds: 0, - Nanos: 0, - }, - } - - var actual pbTSWrapper - decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ - DecodeHook: HookTimeToPBTimestamp, - Result: &actual, - }) - require.NoError(t, err) - require.NoError(t, decoder.Decode(in)) - - require.Equal(t, expected, actual) -} From 76c65e873c2085b542321dad7b15a9c8a8531c22 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 29 Mar 2022 09:34:39 -0400 Subject: [PATCH 2/2] code review changes --- .circleci/config.yml | 3 +- GNUmakefile | 2 + build-support/scripts/proto-gen-entry.sh | 169 ----------------------- 3 files changed, 4 insertions(+), 170 deletions(-) delete mode 100755 build-support/scripts/proto-gen-entry.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index db57fb786e..164c5ddb22 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -237,9 +237,10 @@ jobs: - run: name: Install protobuf command: | + goproto_version=$(go list -m github.com/golang/protobuf | awk '{print $2}') go install -v github.com/hashicorp/protoc-gen-go-binary@master go install -v github.com/favadi/protoc-go-inject-tag@v1.3.0 - go install -v github.com/golang/protobuf/protoc-gen-go@v1.3.5 + go install -v github.com/golang/protobuf/protoc-gen-go@${goproto_version} - run: command: make --always-make proto diff --git a/GNUmakefile b/GNUmakefile index fa9fcb6009..4710fbbaaf 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,11 +2,13 @@ # https://www.consul.io/docs/install#compiling-from-source SHELL = bash +GOPROTOVERSION?=$(shell grep github.com/golang/protobuf go.mod | awk '{print $$2}') GOTOOLS = \ github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs@master \ github.com/hashicorp/go-bindata/go-bindata@master \ golang.org/x/tools/cmd/cover@master \ golang.org/x/tools/cmd/stringer@master \ + github.com/golang/protobuf/protoc-gen-go@$(GOPROTOVERSION) \ github.com/hashicorp/protoc-gen-go-binary@master \ github.com/vektra/mockery/cmd/mockery@master \ github.com/golangci/golangci-lint/cmd/golangci-lint@v1.40.1 \ diff --git a/build-support/scripts/proto-gen-entry.sh b/build-support/scripts/proto-gen-entry.sh deleted file mode 100755 index 50d51be0df..0000000000 --- a/build-support/scripts/proto-gen-entry.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" -pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null -SCRIPT_DIR=$(pwd) -pushd ../.. > /dev/null -SOURCE_DIR=$(pwd) -popd > /dev/null -pushd ../functions > /dev/null -FN_DIR=$(pwd) -popd > /dev/null -popd > /dev/null - -source "${SCRIPT_DIR}/functions.sh" - -function usage { -cat <<-EOF -Usage: ${SCRIPT_NAME} [] - -Description: - Generate the Go files from protobuf definitions. In addition to - running the protoc generator it will also fixup build tags in the - generated code. - -Options: - --import-replace Replace imports of google types with those from the protobuf repo. - --grpc Enable the gRPC plugin - -h | --help Print this help text. -EOF -} - -function err_usage { - err "$1" - err "" - err "$(usage)" -} - -function main { - local -i grpc=0 - local -i imp_replace=0 - local proto_path= - - while test $# -gt 0 - do - case "$1" in - -h | --help ) - usage - return 0 - ;; - --grpc ) - grpc=1 - shift - ;; - --import-replace ) - imp_replace=1 - shift - ;; - * ) - proto_path="$1" - shift - ;; - esac - done - - if test -z "${proto_path}" - then - err_usage "ERROR: No proto file specified" - return 1 - fi - - go mod download - - local golang_proto_path=$(go list -f '{{ .Dir }}' -m github.com/golang/protobuf) - local golang_proto_mod_path=$(sed -e 's,\(.*\)github.com.*,\1,' <<< "${golang_proto_path}") - - - local golang_proto_imp_replace="Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp" - golang_proto_imp_replace="${golang_proto_imp_replace},Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration" - - local proto_go_path=${proto_path%%.proto}.pb.go - local proto_go_bin_path=${proto_path%%.proto}.pb.binary.go - local proto_go_rpcglue_path=${proto_path%%.proto}.rpcglue.pb.go - - local go_proto_out="paths=source_relative" - if is_set "${grpc}" - then - go_proto_out="${go_proto_out},plugins=grpc" - fi - - if is_set "${imp_replace}" - then - go_proto_out="${go_proto_out},${golang_proto_imp_replace}" - fi - - if test -n "${go_proto_out}" - then - go_proto_out="${go_proto_out}:" - fi - - # How we run protoc probably needs some documentation. - # - # This is the path to where - # -I="${golang_proto_path}/protobuf" \ - local -i ret=0 - status_stage "Generating ${proto_path} into ${proto_go_path} and ${proto_go_bin_path} (NO GOGO)" - echo "debug_run protoc \ - -I=\"${golang_proto_path}\" \ - -I=\"${golang_proto_mod_path}\" \ - -I=\"${SOURCE_DIR}\" \ - --go_out=\"${go_proto_out}${SOURCE_DIR}\" \ - --go-binary_out=\"${SOURCE_DIR}\" \ - \"${proto_path}\"" - debug_run protoc \ - -I="${golang_proto_path}" \ - -I="${golang_proto_mod_path}" \ - -I="${SOURCE_DIR}" \ - --go_out="${go_proto_out}${SOURCE_DIR}" \ - --go-binary_out="${SOURCE_DIR}" \ - "${proto_path}" - - if test $? -ne 0 - then - err "Failed to run protoc for ${proto_path}" - return 1 - fi - - debug_run protoc-go-inject-tag \ - -input="${proto_go_path}" - - if test $? -ne 0 - then - err "Failed to run protoc-go-inject-tag for ${proto_path}" - return 1 - fi - - echo "debug_run protoc \ - -I=\"${golang_proto_path}\" \ - -I=\"${golang_proto_mod_path}\" \ - -I=\"${SOURCE_DIR}\" \ - --go_out=\"${go_proto_out}${SOURCE_DIR}\" \ - --go-binary_out=\"${SOURCE_DIR}\" \ - \"${proto_path}\"" - - BUILD_TAGS=$(sed -e '/^[[:space:]]*$/,$d' < "${proto_path}" | grep '// +build') - if test -n "${BUILD_TAGS}" - then - echo -e "${BUILD_TAGS}\n" >> "${proto_go_path}.new" - cat "${proto_go_path}" >> "${proto_go_path}.new" - mv "${proto_go_path}.new" "${proto_go_path}" - - echo -e "${BUILD_TAGS}\n" >> "${proto_go_bin_path}.new" - cat "${proto_go_bin_path}" >> "${proto_go_bin_path}.new" - mv "${proto_go_bin_path}.new" "${proto_go_bin_path}" - fi - - # note: this has to run after we fix up the build tags above - rm -f "${proto_go_rpcglue_path}" - debug_run go run ./internal/tools/proto-gen-rpc-glue/main.go -path "${proto_go_path}" - if test $? -ne 0 - then - err "Failed to generate consul rpc glue outputs from ${proto_path}" - return 1 - fi - - return 0 -} - -main "$@" -exit $?