From 51dcd126b7cfd5df64482e4402ddc5fbea41cd31 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Fri, 20 Sep 2019 14:37:22 -0400 Subject: [PATCH] =?UTF-8?q?Add=20support=20for=20implementing=20new=20requ?= =?UTF-8?q?ests=20with=20protobufs=20instea=E2=80=A6=20(#6502)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add build system support for protobuf generation This is done generically so that we don’t have to keep updating the makefile to add another proto generation. Note: anything not in the vendor directory and with a .proto extension will be run through protoc if the corresponding namespace.pb.go file is not up to date. If you want to rebuild just a single proto file you can do so with: make proto-rebuild PROTOFILES= Providing the PROTOFILES var will override the default behavior of finding all the .proto files. * Start adding types to the agent/proto package These will be needed for some other work and are by no means comprehensive. * Add ability to resolve/fixup the agentpb.ACLLinks structure in the state store. * Use protobuf marshalling of raft requests instead of msgpack for protoc generated types. This does not change any encoding of existing types. * Removed structs package automatically encoding with protobuf marshalling Instead the caller of raftApply that wants to opt-in to protobuf encoding will have to call `raftApplyProtobuf` * Run update-vendor to fixup modules.txt Nothing changed as far as dependencies go but the ordering of modules in that file depends on the time they are first seen and its not alphabetical. * Rename some things and implement the structs.RPCInfo interface bits agentpb.QueryOptions and agentpb.WriteRequest implement 3 of the 4 RPCInfo funcs and the new TargetDatacenter message type implements the fourth. * Use the right encoding function. * Renamed agent/proto package to agent/agentpb to prevent package name conflicts * Update modules.txt to fix ordering * Change blockingQuery to take in interfaces for the query options and meta * Add %T to error output. * Add/Update some comments --- GNUmakefile | 17 +- agent/agentpb/acl.pb.go | 378 ++++++ agent/agentpb/acl.proto | 21 + agent/agentpb/common.go | 81 ++ agent/agentpb/common.pb.go | 1560 ++++++++++++++++++++++++ agent/agentpb/common.proto | 123 ++ agent/agentpb/encoder.go | 35 + agent/connect/ca/plugin/provider.pb.go | 324 +++-- agent/connect/ca/plugin/provider.proto | 2 - agent/consul/rpc.go | 84 +- agent/consul/state/acl.go | 74 ++ agent/consul/state/acl_test.go | 208 ++++ agent/structs/structs.go | 28 + build-support/functions/10-util.sh | 6 + build-support/scripts/proto-gen.sh | 141 +++ vendor/modules.txt | 6 +- 16 files changed, 2939 insertions(+), 149 deletions(-) create mode 100644 agent/agentpb/acl.pb.go create mode 100644 agent/agentpb/acl.proto create mode 100644 agent/agentpb/common.go create mode 100644 agent/agentpb/common.pb.go create mode 100644 agent/agentpb/common.proto create mode 100644 agent/agentpb/encoder.go create mode 100755 build-support/scripts/proto-gen.sh diff --git a/GNUmakefile b/GNUmakefile index 69ccd2d518..f87f2b1b76 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -29,6 +29,9 @@ GIT_DESCRIBE?=$(shell git describe --tags --always --match "v*") GIT_IMPORT=github.com/hashicorp/consul/version GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -X $(GIT_IMPORT).GitDescribe=$(GIT_DESCRIBE) +PROTOFILES?=$(shell find . -name '*.proto' | grep -v 'vendor/') +PROTOGOFILES=$(PROTOFILES:.proto=.pb.go) + ifeq ($(FORCE_REBUILD),1) NOCACHE=--no-cache else @@ -362,8 +365,18 @@ ui-docker: ui-build-image test-envoy-integ: $(ENVOY_INTEG_DEPS) @$(SHELL) $(CURDIR)/test/integration/connect/envoy/run-tests.sh -proto: - protoc agent/connect/ca/plugin/*.proto --gofast_out=plugins=grpc:../../.. +proto-go-delete: + @echo "Removing $(PROTOGOFILES)" + -@rm $(PROTOGOFILES) + +proto-rebuild: proto-go-delete proto + +proto: $(PROTOGOFILES) + @echo "Generated all protobuf Go files" + +%.pb.go: %.proto + @$(SHELL) $(CURDIR)/build-support/scripts/proto-gen.sh --grpc --import-replace --generator gogo "$<" + .PHONY: all ci bin dev dist cov test test-ci test-internal test-install-deps cover format vet ui static-assets tools .PHONY: docker-images go-build-image ui-build-image static-assets-docker consul-docker ui-docker diff --git a/agent/agentpb/acl.pb.go b/agent/agentpb/acl.pb.go new file mode 100644 index 0000000000..b30a5a7956 --- /dev/null +++ b/agent/agentpb/acl.pb.go @@ -0,0 +1,378 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: acl.proto + +package agentpb + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/golang/protobuf/proto" + io "io" + math "math" +) + +// 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.ProtoPackageIsVersion2 // please upgrade the proto package + +type ACLLink struct { + ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty" hash:"ignore"` +} + +func (m *ACLLink) Reset() { *m = ACLLink{} } +func (m *ACLLink) String() string { return proto.CompactTextString(m) } +func (*ACLLink) ProtoMessage() {} +func (*ACLLink) Descriptor() ([]byte, []int) { + return fileDescriptor_a452f070aeef01eb, []int{0} +} +func (m *ACLLink) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(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.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ACLLink) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLLink.Merge(m, src) +} +func (m *ACLLink) XXX_Size() int { + return m.Size() +} +func (m *ACLLink) XXX_DiscardUnknown() { + xxx_messageInfo_ACLLink.DiscardUnknown(m) +} + +var xxx_messageInfo_ACLLink proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ACLLink)(nil), "agentpb.ACLLink") +} + +func init() { proto.RegisterFile("acl.proto", fileDescriptor_a452f070aeef01eb) } + +var fileDescriptor_a452f070aeef01eb = []byte{ + // 159 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4c, 0x4c, 0xce, 0xd1, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4f, 0x4c, 0x4f, 0xcd, 0x2b, 0x29, 0x48, 0x92, 0x12, + 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x8b, 0xe9, 0x83, 0x58, 0x10, 0x69, 0x25, 0x07, 0x2e, 0x76, 0x47, + 0x67, 0x1f, 0x9f, 0xcc, 0xbc, 0x6c, 0x21, 0x3e, 0x2e, 0x26, 0x4f, 0x17, 0x09, 0x46, 0x05, 0x46, + 0x0d, 0xce, 0x20, 0x26, 0x4f, 0x17, 0x21, 0x55, 0x2e, 0x16, 0xbf, 0xc4, 0xdc, 0x54, 0x09, 0x26, + 0x90, 0x88, 0x93, 0xe0, 0xa7, 0x7b, 0xf2, 0xbc, 0x19, 0x89, 0xc5, 0x19, 0x56, 0x4a, 0x99, 0xe9, + 0x79, 0xf9, 0x45, 0xa9, 0x4a, 0x41, 0x60, 0x69, 0x27, 0x85, 0x13, 0x0f, 0xe5, 0x18, 0x4e, 0x3c, + 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x66, + 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x24, 0x36, 0xb0, 0x55, + 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0e, 0xc8, 0xbd, 0xdf, 0x96, 0x00, 0x00, 0x00, +} + +func (m *ACLLink) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ACLLink) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ID) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintAcl(dAtA, i, uint64(len(m.ID))) + i += copy(dAtA[i:], m.ID) + } + if len(m.Name) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintAcl(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + return i, nil +} + +func encodeVarintAcl(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +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)) + } + return n +} + +func sovAcl(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +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 { + return ErrInvalidLengthAcl + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthAcl + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAcl(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 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 + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + 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 + if iNdEx < 0 { + return 0, ErrInvalidLengthAcl + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAcl + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipAcl(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + if iNdEx < 0 { + return 0, ErrInvalidLengthAcl + } + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthAcl = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAcl = fmt.Errorf("proto: integer overflow") +) diff --git a/agent/agentpb/acl.proto b/agent/agentpb/acl.proto new file mode 100644 index 0000000000..aab4deb298 --- /dev/null +++ b/agent/agentpb/acl.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package agentpb; + +// 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; + +message ACLLink { + string ID = 1; + string Name = 2 + [(gogoproto.moretags) = "hash:\"ignore\""]; +} \ No newline at end of file diff --git a/agent/agentpb/common.go b/agent/agentpb/common.go new file mode 100644 index 0000000000..3b08ceb7f0 --- /dev/null +++ b/agent/agentpb/common.go @@ -0,0 +1,81 @@ +package agentpb + +import ( + "time" +) + +// 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 +} + +// TokenSecret returns the token to be used to authorize the request +func (q *QueryOptions) TokenSecret() string { + return q.Token +} + +// GetMinQueryIndex implements the interface necessary to be used +// in a blocking query +func (q *QueryOptions) GetMinQueryIndex() uint64 { + return q.MinQueryIndex +} + +// GetMaxQueryTime implements the interface necessary to be used +// in a blocking query +func (q *QueryOptions) GetMaxQueryTime() time.Duration { + return q.MaxQueryTime +} + +// GetRequireConsistent implements the interface necessary to be used +// in a blocking query +func (q *QueryOptions) GetRequireConsistent() bool { + return q.RequireConsistent +} + +// SetLastContact implements the interface necessary to be used +// in a blocking query +func (q *QueryMeta) SetLastContact(lastContact time.Duration) { + q.LastContact = lastContact +} + +// SetKnownLeader implements the interface necessary to be used +// in a blocking query +func (q *QueryMeta) SetKnownLeader(knownLeader bool) { + q.KnownLeader = knownLeader +} + +// GetIndex implements the interface necessary to be used +// in a blocking query +func (q *QueryMeta) GetIndex() uint64 { + return q.Index +} + +// SetIndex implements the interface necessary to be used +// in a blocking query +func (q *QueryMeta) SetIndex(index uint64) { + q.Index = index +} + +// WriteRequest only applies to writes, always false +func (w WriteRequest) IsRead() bool { + return false +} + +// AllowStaleRead returns whether a stale read should be allowed +func (w WriteRequest) AllowStaleRead() bool { + return false +} + +// TokenSecret returns the token to be used to authorize the request +func (w WriteRequest) TokenSecret() string { + return w.Token +} + +func (td TargetDatacenter) RequestDatacenter() string { + return td.Datacenter +} diff --git a/agent/agentpb/common.pb.go b/agent/agentpb/common.pb.go new file mode 100644 index 0000000000..95009c5431 --- /dev/null +++ b/agent/agentpb/common.pb.go @@ -0,0 +1,1560 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: common.proto + +package agentpb + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + _ "github.com/gogo/protobuf/types" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + proto "github.com/golang/protobuf/proto" + io "io" + math "math" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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.ProtoPackageIsVersion2 // please upgrade the proto package + +// RaftIndex is used to track the index used while creating +// or modifying a given struct type. +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_555bd8c177793206, []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.MarshalTo(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_555bd8c177793206, []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.MarshalTo(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_555bd8c177793206, []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.MarshalTo(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 + +// QueryOptions is used to specify various flags for read queries +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. + MaxQueryTime time.Duration `protobuf:"bytes,3,opt,name=MaxQueryTime,proto3,stdduration" 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. + MaxStaleDuration time.Duration `protobuf:"bytes,7,opt,name=MaxStaleDuration,proto3,stdduration" 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. + MaxAge time.Duration `protobuf:"bytes,8,opt,name=MaxAge,proto3,stdduration" 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 time.Duration `protobuf:"bytes,10,opt,name=StaleIfError,proto3,stdduration" 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_555bd8c177793206, []int{3} +} +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.MarshalTo(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 +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. + LastContact time.Duration `protobuf:"bytes,2,opt,name=LastContact,proto3,stdduration" 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"` +} + +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_555bd8c177793206, []int{4} +} +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.MarshalTo(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 + +func init() { + proto.RegisterType((*RaftIndex)(nil), "agentpb.RaftIndex") + proto.RegisterType((*TargetDatacenter)(nil), "agentpb.TargetDatacenter") + proto.RegisterType((*WriteRequest)(nil), "agentpb.WriteRequest") + proto.RegisterType((*QueryOptions)(nil), "agentpb.QueryOptions") + proto.RegisterType((*QueryMeta)(nil), "agentpb.QueryMeta") +} + +func init() { proto.RegisterFile("common.proto", fileDescriptor_555bd8c177793206) } + +var fileDescriptor_555bd8c177793206 = []byte{ + // 529 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x41, 0x6f, 0x12, 0x4f, + 0x1c, 0xdd, 0xfd, 0xff, 0x29, 0x65, 0x7f, 0x50, 0x83, 0x93, 0xc6, 0xac, 0x1c, 0x06, 0xb2, 0x69, + 0x0c, 0x31, 0x0a, 0x49, 0xbd, 0xe9, 0xa9, 0xd0, 0x6a, 0x1a, 0xd9, 0x34, 0x8e, 0x18, 0xcf, 0x03, + 0xfc, 0x58, 0x37, 0x2e, 0x33, 0x38, 0x3b, 0xb4, 0xf0, 0x2d, 0x3c, 0x78, 0xe8, 0x27, 0xf1, 0x33, + 0x70, 0xec, 0xd1, 0x53, 0x55, 0xf8, 0x06, 0x7e, 0x02, 0xb3, 0xb3, 0x50, 0xb7, 0xd2, 0x03, 0xde, + 0xf6, 0xbd, 0x7d, 0x6f, 0xe6, 0xcd, 0xef, 0xf7, 0xa0, 0xd4, 0x97, 0xa3, 0x91, 0x14, 0x8d, 0xb1, + 0x92, 0x5a, 0x92, 0x5d, 0x1e, 0xa0, 0xd0, 0xe3, 0x5e, 0x85, 0x06, 0x52, 0x06, 0x11, 0x36, 0x0d, + 0xdd, 0x9b, 0x0c, 0x9b, 0x83, 0x89, 0xe2, 0x3a, 0x5c, 0x0b, 0x2b, 0xfb, 0x81, 0x0c, 0xa4, 0xf9, + 0x6c, 0x26, 0x5f, 0x29, 0xeb, 0x8d, 0xc0, 0x61, 0x7c, 0xa8, 0x4f, 0xc5, 0x00, 0xa7, 0xa4, 0x09, + 0xc5, 0xb6, 0x42, 0xae, 0xd1, 0x40, 0xd7, 0xae, 0xd9, 0xf5, 0x5c, 0x6b, 0xef, 0xd7, 0x75, 0xd5, + 0xe9, 0xe1, 0x74, 0xac, 0x9e, 0x7b, 0x4f, 0x3d, 0x96, 0x55, 0x24, 0x06, 0x5f, 0x0e, 0xc2, 0xe1, + 0x2c, 0x35, 0xfc, 0x77, 0xa7, 0x21, 0xa3, 0xf0, 0x0e, 0xa1, 0xdc, 0xe5, 0x2a, 0x40, 0x7d, 0xcc, + 0x35, 0xef, 0xa3, 0xd0, 0xa8, 0x08, 0x05, 0xf8, 0x83, 0xcc, 0xa5, 0x0e, 0xcb, 0x30, 0xde, 0x01, + 0x94, 0xde, 0xab, 0x50, 0x23, 0xc3, 0x4f, 0x13, 0x8c, 0x35, 0xd9, 0x87, 0x9d, 0xae, 0xfc, 0x88, + 0x62, 0x25, 0x4d, 0x81, 0xf7, 0x25, 0x07, 0xa5, 0x37, 0x13, 0x54, 0xb3, 0xb3, 0x71, 0xf2, 0xe8, + 0xf8, 0x6e, 0x19, 0x39, 0x80, 0x3d, 0x3f, 0x14, 0x46, 0x98, 0xc9, 0xcc, 0x6e, 0x93, 0xe4, 0x15, + 0x94, 0x7c, 0x3e, 0x35, 0x44, 0x37, 0x1c, 0xa1, 0xfb, 0x7f, 0xcd, 0xae, 0x17, 0x0f, 0x1f, 0x36, + 0xd2, 0x11, 0x37, 0xd6, 0x23, 0x6e, 0x1c, 0xaf, 0x46, 0xdc, 0x2a, 0xcc, 0xaf, 0xab, 0xd6, 0xe5, + 0xf7, 0xaa, 0xcd, 0x6e, 0x19, 0x93, 0xb7, 0x1d, 0x45, 0x91, 0xbc, 0x78, 0xab, 0x79, 0x84, 0x6e, + 0xae, 0x66, 0xd7, 0x0b, 0x2c, 0xc3, 0x90, 0x27, 0x70, 0x3f, 0x79, 0x56, 0xa8, 0xb0, 0x2d, 0x45, + 0x1c, 0xc6, 0x1a, 0x85, 0x76, 0x77, 0x8c, 0x6c, 0xf3, 0x07, 0xa9, 0x40, 0xe1, 0x5d, 0x8c, 0x6d, + 0xde, 0xff, 0x80, 0x6e, 0xde, 0x88, 0x6e, 0x30, 0x39, 0x83, 0xb2, 0xcf, 0xa7, 0xe6, 0xd4, 0x75, + 0x2a, 0x77, 0x77, 0xfb, 0xd8, 0x1b, 0x66, 0xf2, 0x02, 0xf2, 0x3e, 0x9f, 0x1e, 0x05, 0xe8, 0x16, + 0xb6, 0x3f, 0x66, 0x65, 0x21, 0x8f, 0xe0, 0x9e, 0x3f, 0x89, 0x35, 0xc3, 0x73, 0x1e, 0x85, 0x03, + 0xae, 0xd1, 0x75, 0x4c, 0xde, 0xbf, 0xd8, 0x64, 0xd0, 0xe6, 0xd6, 0xd3, 0xe1, 0x89, 0x52, 0x52, + 0xb9, 0xf0, 0x0f, 0x83, 0xce, 0x1a, 0xc9, 0x03, 0xc8, 0xbf, 0x0c, 0xa3, 0xa4, 0x40, 0x45, 0xb3, + 0xee, 0x15, 0xf2, 0xbe, 0xda, 0xe0, 0x98, 0x75, 0xf8, 0xa8, 0x79, 0xd2, 0x89, 0x4c, 0xb5, 0x59, + 0x0a, 0xc8, 0x09, 0x14, 0x3b, 0x3c, 0xd6, 0x6d, 0x29, 0x34, 0xef, 0x6b, 0xd3, 0x88, 0x2d, 0x33, + 0x64, 0x7d, 0xa4, 0x06, 0xc5, 0xd7, 0x42, 0x5e, 0x88, 0x0e, 0xf2, 0x01, 0x2a, 0xd3, 0x99, 0x02, + 0xcb, 0x52, 0xe4, 0x31, 0x94, 0x6f, 0xb6, 0xd9, 0x9f, 0x75, 0xf0, 0x1c, 0x23, 0xd3, 0x09, 0x87, + 0x6d, 0xf0, 0xad, 0xda, 0xfc, 0x27, 0xb5, 0xe6, 0x0b, 0x6a, 0x5f, 0x2d, 0xa8, 0xfd, 0x63, 0x41, + 0xed, 0xcf, 0x4b, 0x6a, 0x5d, 0x2e, 0xa9, 0x75, 0xb5, 0xa4, 0xd6, 0xb7, 0x25, 0xb5, 0x7a, 0x79, + 0x93, 0xec, 0xd9, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x68, 0x40, 0xc8, 0x10, 0x04, 0x00, + 0x00, +} + +func (m *RaftIndex) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RaftIndex) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.CreateIndex != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintCommon(dAtA, i, uint64(m.CreateIndex)) + } + if m.ModifyIndex != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintCommon(dAtA, i, uint64(m.ModifyIndex)) + } + return i, nil +} + +func (m *TargetDatacenter) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TargetDatacenter) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Datacenter) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintCommon(dAtA, i, uint64(len(m.Datacenter))) + i += copy(dAtA[i:], m.Datacenter) + } + return i, nil +} + +func (m *WriteRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *WriteRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Token) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintCommon(dAtA, i, uint64(len(m.Token))) + i += copy(dAtA[i:], m.Token) + } + return i, nil +} + +func (m *QueryOptions) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryOptions) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Token) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintCommon(dAtA, i, uint64(len(m.Token))) + i += copy(dAtA[i:], m.Token) + } + if m.MinQueryIndex != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintCommon(dAtA, i, uint64(m.MinQueryIndex)) + } + dAtA[i] = 0x1a + i++ + i = encodeVarintCommon(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxQueryTime))) + n1, err := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxQueryTime, dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + if m.AllowStale { + dAtA[i] = 0x20 + i++ + if m.AllowStale { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if m.RequireConsistent { + dAtA[i] = 0x28 + i++ + if m.RequireConsistent { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if m.UseCache { + dAtA[i] = 0x30 + i++ + if m.UseCache { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + dAtA[i] = 0x3a + i++ + i = encodeVarintCommon(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxStaleDuration))) + n2, err := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxStaleDuration, dAtA[i:]) + if err != nil { + return 0, err + } + i += n2 + dAtA[i] = 0x42 + i++ + i = encodeVarintCommon(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAge))) + n3, err := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAge, dAtA[i:]) + if err != nil { + return 0, err + } + i += n3 + if m.MustRevalidate { + dAtA[i] = 0x48 + i++ + if m.MustRevalidate { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + dAtA[i] = 0x52 + i++ + i = encodeVarintCommon(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdDuration(m.StaleIfError))) + n4, err := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.StaleIfError, dAtA[i:]) + if err != nil { + return 0, err + } + i += n4 + if len(m.Filter) > 0 { + dAtA[i] = 0x5a + i++ + i = encodeVarintCommon(dAtA, i, uint64(len(m.Filter))) + i += copy(dAtA[i:], m.Filter) + } + return i, nil +} + +func (m *QueryMeta) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryMeta) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Index != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintCommon(dAtA, i, uint64(m.Index)) + } + dAtA[i] = 0x12 + i++ + i = encodeVarintCommon(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdDuration(m.LastContact))) + n5, err := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.LastContact, dAtA[i:]) + if err != nil { + return 0, err + } + i += n5 + if m.KnownLeader { + dAtA[i] = 0x18 + i++ + if m.KnownLeader { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if len(m.ConsistencyLevel) > 0 { + dAtA[i] = 0x22 + i++ + i = encodeVarintCommon(dAtA, i, uint64(len(m.ConsistencyLevel))) + i += copy(dAtA[i:], m.ConsistencyLevel) + } + return i, nil +} + +func encodeVarintCommon(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +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 *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 = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxQueryTime) + n += 1 + l + sovCommon(uint64(l)) + if m.AllowStale { + n += 2 + } + if m.RequireConsistent { + n += 2 + } + if m.UseCache { + n += 2 + } + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxStaleDuration) + n += 1 + l + sovCommon(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAge) + n += 1 + l + sovCommon(uint64(l)) + if m.MustRevalidate { + n += 2 + } + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.StaleIfError) + 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 = github_com_gogo_protobuf_types.SizeOfStdDuration(m.LastContact) + n += 1 + l + sovCommon(uint64(l)) + if m.KnownLeader { + n += 2 + } + l = len(m.ConsistencyLevel) + if l > 0 { + n += 1 + l + sovCommon(uint64(l)) + } + return n +} + +func sovCommon(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +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 { + return ErrInvalidLengthCommon + } + if (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 { + return ErrInvalidLengthCommon + } + if (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 { + return ErrInvalidLengthCommon + } + if (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 := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxQueryTime, 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 := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxStaleDuration, 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 := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxAge, 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 := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.StaleIfError, 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 { + return ErrInvalidLengthCommon + } + if (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 := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.LastContact, 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 + default: + iNdEx = preIndex + skippy, err := skipCommon(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCommon + } + if (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 + 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 + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + 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 + if iNdEx < 0 { + return 0, ErrInvalidLengthCommon + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCommon + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipCommon(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + if iNdEx < 0 { + return 0, ErrInvalidLengthCommon + } + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthCommon = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCommon = fmt.Errorf("proto: integer overflow") +) diff --git a/agent/agentpb/common.proto b/agent/agentpb/common.proto new file mode 100644 index 0000000000..0528cbfa4a --- /dev/null +++ b/agent/agentpb/common.proto @@ -0,0 +1,123 @@ +syntax = "proto3"; + +package agentpb; + +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. +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; +} + +// QueryOptions is used to specify various flags for read queries +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. + google.protobuf.Duration MaxQueryTime = 3 + [(gogoproto.stdduration) = true, (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. + google.protobuf.Duration MaxStaleDuration = 7 + [(gogoproto.stdduration) = true, (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. + google.protobuf.Duration MaxAge = 8 + [(gogoproto.stdduration) = true, (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.stdduration) = true, (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 +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. + google.protobuf.Duration LastContact = 2 + [(gogoproto.stdduration) = true, (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; +} diff --git a/agent/agentpb/encoder.go b/agent/agentpb/encoder.go new file mode 100644 index 0000000000..1792993b7f --- /dev/null +++ b/agent/agentpb/encoder.go @@ -0,0 +1,35 @@ +package agentpb + +import ( + "fmt" + + "github.com/hashicorp/consul/agent/structs" +) + +type ProtoMarshaller interface { + Size() int + MarshalTo([]byte) (int, error) + Unmarshal([]byte) error + ProtoMessage() +} + +func EncodeInterface(t structs.MessageType, message interface{}) ([]byte, error) { + if marshaller, ok := message.(ProtoMarshaller); ok { + return Encode(t, marshaller) + } + return nil, fmt.Errorf("message does not implement the ProtoMarshaller interface: %T", message) +} + +func Encode(t structs.MessageType, message ProtoMarshaller) ([]byte, error) { + data := make([]byte, message.Size()+1) + data[0] = uint8(t) + if _, err := message.MarshalTo(data[1:]); err != nil { + return nil, err + } + return data, nil +} + +func Decode(buf []byte, out ProtoMarshaller) error { + // Note that this assumes the leading byte indicating the type has already been stripped off + return out.Unmarshal(buf) +} diff --git a/agent/connect/ca/plugin/provider.pb.go b/agent/connect/ca/plugin/provider.pb.go index 8c15dcdc07..fcafb0b155 100644 --- a/agent/connect/ca/plugin/provider.pb.go +++ b/agent/connect/ca/plugin/provider.pb.go @@ -1,19 +1,17 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: agent/connect/ca/plugin/provider.proto +// source: provider.proto -package plugin // import "github.com/hashicorp/consul/agent/connect/ca/plugin" - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +package plugin import ( - context "golang.org/x/net/context" + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" + io "io" + math "math" ) -import io "io" - // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf @@ -38,7 +36,7 @@ func (m *ConfigureRequest) Reset() { *m = ConfigureRequest{} } func (m *ConfigureRequest) String() string { return proto.CompactTextString(m) } func (*ConfigureRequest) ProtoMessage() {} func (*ConfigureRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{0} + return fileDescriptor_c6a9f3c02af3d1c8, []int{0} } func (m *ConfigureRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -55,8 +53,8 @@ func (m *ConfigureRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (dst *ConfigureRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConfigureRequest.Merge(dst, src) +func (m *ConfigureRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConfigureRequest.Merge(m, src) } func (m *ConfigureRequest) XXX_Size() int { return m.Size() @@ -100,7 +98,7 @@ func (m *SetIntermediateRequest) Reset() { *m = SetIntermediateRequest{} func (m *SetIntermediateRequest) String() string { return proto.CompactTextString(m) } func (*SetIntermediateRequest) ProtoMessage() {} func (*SetIntermediateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{1} + return fileDescriptor_c6a9f3c02af3d1c8, []int{1} } func (m *SetIntermediateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -117,8 +115,8 @@ func (m *SetIntermediateRequest) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (dst *SetIntermediateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SetIntermediateRequest.Merge(dst, src) +func (m *SetIntermediateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetIntermediateRequest.Merge(m, src) } func (m *SetIntermediateRequest) XXX_Size() int { return m.Size() @@ -154,7 +152,7 @@ func (m *SignRequest) Reset() { *m = SignRequest{} } func (m *SignRequest) String() string { return proto.CompactTextString(m) } func (*SignRequest) ProtoMessage() {} func (*SignRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{2} + return fileDescriptor_c6a9f3c02af3d1c8, []int{2} } func (m *SignRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -171,8 +169,8 @@ func (m *SignRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (dst *SignRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SignRequest.Merge(dst, src) +func (m *SignRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignRequest.Merge(m, src) } func (m *SignRequest) XXX_Size() int { return m.Size() @@ -201,7 +199,7 @@ func (m *SignIntermediateRequest) Reset() { *m = SignIntermediateRequest func (m *SignIntermediateRequest) String() string { return proto.CompactTextString(m) } func (*SignIntermediateRequest) ProtoMessage() {} func (*SignIntermediateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{3} + return fileDescriptor_c6a9f3c02af3d1c8, []int{3} } func (m *SignIntermediateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -218,8 +216,8 @@ func (m *SignIntermediateRequest) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (dst *SignIntermediateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SignIntermediateRequest.Merge(dst, src) +func (m *SignIntermediateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignIntermediateRequest.Merge(m, src) } func (m *SignIntermediateRequest) XXX_Size() int { return m.Size() @@ -248,7 +246,7 @@ func (m *CrossSignCARequest) Reset() { *m = CrossSignCARequest{} } func (m *CrossSignCARequest) String() string { return proto.CompactTextString(m) } func (*CrossSignCARequest) ProtoMessage() {} func (*CrossSignCARequest) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{4} + return fileDescriptor_c6a9f3c02af3d1c8, []int{4} } func (m *CrossSignCARequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -265,8 +263,8 @@ func (m *CrossSignCARequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (dst *CrossSignCARequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CrossSignCARequest.Merge(dst, src) +func (m *CrossSignCARequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CrossSignCARequest.Merge(m, src) } func (m *CrossSignCARequest) XXX_Size() int { return m.Size() @@ -295,7 +293,7 @@ func (m *ActiveRootResponse) Reset() { *m = ActiveRootResponse{} } func (m *ActiveRootResponse) String() string { return proto.CompactTextString(m) } func (*ActiveRootResponse) ProtoMessage() {} func (*ActiveRootResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{5} + return fileDescriptor_c6a9f3c02af3d1c8, []int{5} } func (m *ActiveRootResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -312,8 +310,8 @@ func (m *ActiveRootResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (dst *ActiveRootResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ActiveRootResponse.Merge(dst, src) +func (m *ActiveRootResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ActiveRootResponse.Merge(m, src) } func (m *ActiveRootResponse) XXX_Size() int { return m.Size() @@ -342,7 +340,7 @@ func (m *GenerateIntermediateCSRResponse) Reset() { *m = GenerateInterme func (m *GenerateIntermediateCSRResponse) String() string { return proto.CompactTextString(m) } func (*GenerateIntermediateCSRResponse) ProtoMessage() {} func (*GenerateIntermediateCSRResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{6} + return fileDescriptor_c6a9f3c02af3d1c8, []int{6} } func (m *GenerateIntermediateCSRResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -359,8 +357,8 @@ func (m *GenerateIntermediateCSRResponse) XXX_Marshal(b []byte, deterministic bo return b[:n], nil } } -func (dst *GenerateIntermediateCSRResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenerateIntermediateCSRResponse.Merge(dst, src) +func (m *GenerateIntermediateCSRResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenerateIntermediateCSRResponse.Merge(m, src) } func (m *GenerateIntermediateCSRResponse) XXX_Size() int { return m.Size() @@ -389,7 +387,7 @@ func (m *ActiveIntermediateResponse) Reset() { *m = ActiveIntermediateRe func (m *ActiveIntermediateResponse) String() string { return proto.CompactTextString(m) } func (*ActiveIntermediateResponse) ProtoMessage() {} func (*ActiveIntermediateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{7} + return fileDescriptor_c6a9f3c02af3d1c8, []int{7} } func (m *ActiveIntermediateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -406,8 +404,8 @@ func (m *ActiveIntermediateResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (dst *ActiveIntermediateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ActiveIntermediateResponse.Merge(dst, src) +func (m *ActiveIntermediateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ActiveIntermediateResponse.Merge(m, src) } func (m *ActiveIntermediateResponse) XXX_Size() int { return m.Size() @@ -436,7 +434,7 @@ func (m *GenerateIntermediateResponse) Reset() { *m = GenerateIntermedia func (m *GenerateIntermediateResponse) String() string { return proto.CompactTextString(m) } func (*GenerateIntermediateResponse) ProtoMessage() {} func (*GenerateIntermediateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{8} + return fileDescriptor_c6a9f3c02af3d1c8, []int{8} } func (m *GenerateIntermediateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -453,8 +451,8 @@ func (m *GenerateIntermediateResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (dst *GenerateIntermediateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenerateIntermediateResponse.Merge(dst, src) +func (m *GenerateIntermediateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenerateIntermediateResponse.Merge(m, src) } func (m *GenerateIntermediateResponse) XXX_Size() int { return m.Size() @@ -483,7 +481,7 @@ func (m *SignResponse) Reset() { *m = SignResponse{} } func (m *SignResponse) String() string { return proto.CompactTextString(m) } func (*SignResponse) ProtoMessage() {} func (*SignResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{9} + return fileDescriptor_c6a9f3c02af3d1c8, []int{9} } func (m *SignResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -500,8 +498,8 @@ func (m *SignResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (dst *SignResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_SignResponse.Merge(dst, src) +func (m *SignResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignResponse.Merge(m, src) } func (m *SignResponse) XXX_Size() int { return m.Size() @@ -530,7 +528,7 @@ func (m *SignIntermediateResponse) Reset() { *m = SignIntermediateRespon func (m *SignIntermediateResponse) String() string { return proto.CompactTextString(m) } func (*SignIntermediateResponse) ProtoMessage() {} func (*SignIntermediateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{10} + return fileDescriptor_c6a9f3c02af3d1c8, []int{10} } func (m *SignIntermediateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -547,8 +545,8 @@ func (m *SignIntermediateResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (dst *SignIntermediateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_SignIntermediateResponse.Merge(dst, src) +func (m *SignIntermediateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignIntermediateResponse.Merge(m, src) } func (m *SignIntermediateResponse) XXX_Size() int { return m.Size() @@ -577,7 +575,7 @@ func (m *CrossSignCAResponse) Reset() { *m = CrossSignCAResponse{} } func (m *CrossSignCAResponse) String() string { return proto.CompactTextString(m) } func (*CrossSignCAResponse) ProtoMessage() {} func (*CrossSignCAResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{11} + return fileDescriptor_c6a9f3c02af3d1c8, []int{11} } func (m *CrossSignCAResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -594,8 +592,8 @@ func (m *CrossSignCAResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (dst *CrossSignCAResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CrossSignCAResponse.Merge(dst, src) +func (m *CrossSignCAResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CrossSignCAResponse.Merge(m, src) } func (m *CrossSignCAResponse) XXX_Size() int { return m.Size() @@ -625,7 +623,7 @@ func (m *Empty) Reset() { *m = Empty{} } func (m *Empty) String() string { return proto.CompactTextString(m) } func (*Empty) ProtoMessage() {} func (*Empty) Descriptor() ([]byte, []int) { - return fileDescriptor_provider_8ff2d2670790989c, []int{12} + return fileDescriptor_c6a9f3c02af3d1c8, []int{12} } func (m *Empty) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -642,8 +640,8 @@ func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (dst *Empty) XXX_Merge(src proto.Message) { - xxx_messageInfo_Empty.Merge(dst, src) +func (m *Empty) XXX_Merge(src proto.Message) { + xxx_messageInfo_Empty.Merge(m, src) } func (m *Empty) XXX_Size() int { return m.Size() @@ -670,6 +668,45 @@ func init() { proto.RegisterType((*Empty)(nil), "plugin.Empty") } +func init() { proto.RegisterFile("provider.proto", fileDescriptor_c6a9f3c02af3d1c8) } + +var fileDescriptor_c6a9f3c02af3d1c8 = []byte{ + // 523 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0xfd, 0x9c, 0x7e, 0x75, 0x9a, 0xdb, 0x40, 0xad, 0x69, 0xd5, 0x18, 0x03, 0x4e, 0x64, 0x21, + 0x12, 0x04, 0x44, 0x82, 0x82, 0x2a, 0xb1, 0x22, 0x58, 0x50, 0x55, 0x6c, 0x8a, 0x23, 0xb6, 0x44, + 0xa9, 0x73, 0x89, 0x46, 0x8a, 0x3d, 0x66, 0x66, 0x5c, 0x89, 0x37, 0xe1, 0x8d, 0x60, 0xc9, 0x23, + 0xa0, 0xf0, 0x22, 0xc8, 0x8e, 0xed, 0xda, 0x13, 0xb7, 0xde, 0x79, 0xee, 0x9c, 0x73, 0xee, 0xdf, + 0x19, 0xc3, 0xdd, 0x88, 0xb3, 0x2b, 0xba, 0x40, 0x3e, 0x8e, 0x38, 0x93, 0x8c, 0xe8, 0xd1, 0x2a, + 0x5e, 0xd2, 0xd0, 0xb9, 0x04, 0xc3, 0x65, 0xe1, 0x57, 0xba, 0x8c, 0x39, 0x7a, 0xf8, 0x2d, 0x46, + 0x21, 0xc9, 0x43, 0x00, 0x7f, 0x15, 0x0b, 0x89, 0x7c, 0x46, 0x17, 0xa6, 0x36, 0xd0, 0x46, 0x1d, + 0xaf, 0x93, 0x45, 0xce, 0x17, 0xa4, 0x07, 0x6d, 0x2a, 0x66, 0x9c, 0x31, 0x69, 0xb6, 0x06, 0xda, + 0x68, 0xcf, 0xd3, 0xa9, 0xf0, 0x18, 0x93, 0xe4, 0x18, 0x74, 0x3f, 0xd5, 0x32, 0x77, 0x06, 0xda, + 0xa8, 0xeb, 0x65, 0x27, 0xe7, 0x0b, 0x1c, 0x4f, 0x51, 0x9e, 0x87, 0x12, 0x79, 0x80, 0x0b, 0x3a, + 0x97, 0x45, 0xa6, 0x27, 0x60, 0xd0, 0x52, 0x78, 0x16, 0x61, 0x90, 0xe5, 0x3b, 0x28, 0xc7, 0x2f, + 0x30, 0x20, 0xf7, 0x60, 0x2f, 0x49, 0x99, 0x42, 0x5a, 0x29, 0xa4, 0x9d, 0x9c, 0x2f, 0x30, 0x70, + 0xfa, 0xb0, 0x3f, 0xa5, 0xcb, 0x30, 0x17, 0x35, 0x60, 0xc7, 0x17, 0x3c, 0xd5, 0xe9, 0x7a, 0xc9, + 0xa7, 0xf3, 0x14, 0x7a, 0x09, 0xa0, 0xae, 0x82, 0x6d, 0xf0, 0x63, 0x20, 0x2e, 0x67, 0x42, 0x24, + 0x0c, 0x77, 0x52, 0xc6, 0x71, 0x59, 0xe0, 0xb8, 0x74, 0x9e, 0x03, 0x99, 0xf8, 0x92, 0x5e, 0x61, + 0xd2, 0xbb, 0x87, 0x22, 0x62, 0xa1, 0xc0, 0x64, 0x38, 0x3e, 0x97, 0xa5, 0x46, 0x74, 0x9f, 0xa7, + 0x45, 0xbe, 0x81, 0xfe, 0x19, 0x86, 0xc8, 0xe7, 0x12, 0xcb, 0x75, 0xb8, 0x53, 0xaf, 0xc2, 0x15, + 0xbc, 0xc2, 0x15, 0x3c, 0xe1, 0xbe, 0x06, 0x6b, 0x93, 0xaa, 0xda, 0x41, 0x53, 0xca, 0x53, 0x78, + 0x50, 0x97, 0xb2, 0x99, 0x38, 0x84, 0xee, 0x66, 0xa0, 0x4d, 0xc0, 0x13, 0x30, 0xb7, 0x07, 0xdb, + 0x44, 0x1a, 0xc3, 0x61, 0x65, 0xc0, 0x4d, 0xf8, 0x36, 0xec, 0xbe, 0x0f, 0x22, 0xf9, 0xfd, 0xe5, + 0xcf, 0x5d, 0x68, 0xb9, 0x13, 0xf2, 0x0a, 0x3a, 0x85, 0x65, 0x89, 0x39, 0xde, 0x18, 0x79, 0xac, + 0xba, 0xd8, 0xba, 0x93, 0xdf, 0xa4, 0x64, 0xf2, 0x0c, 0xba, 0xf9, 0x30, 0x52, 0xb3, 0x56, 0xaf, + 0x55, 0xf4, 0x29, 0xc0, 0xf5, 0x72, 0x55, 0xac, 0x95, 0x1f, 0x6b, 0xf6, 0xff, 0x09, 0x7a, 0x37, + 0xac, 0x59, 0x55, 0x19, 0xe6, 0xc7, 0x26, 0x5b, 0xbc, 0x85, 0x03, 0xe5, 0xf9, 0x10, 0x3b, 0xe7, + 0xd6, 0xbf, 0x2b, 0xb5, 0x9b, 0xb3, 0xdc, 0xaa, 0x15, 0x11, 0xa5, 0x1e, 0xa7, 0xda, 0x55, 0xed, + 0x4e, 0x3f, 0xc2, 0x51, 0x5d, 0xb5, 0xaa, 0xd4, 0xa3, 0xdb, 0x5a, 0x2b, 0xc4, 0x5e, 0xc0, 0xff, + 0x89, 0x05, 0xc8, 0x61, 0xd1, 0xcc, 0xf5, 0x23, 0xb6, 0x8e, 0xaa, 0xc1, 0x8c, 0xf2, 0x19, 0x0c, + 0xd5, 0x6f, 0xa4, 0x5f, 0x46, 0xd6, 0x0d, 0x63, 0x70, 0x33, 0x20, 0x93, 0xfd, 0x00, 0xfb, 0x25, + 0x47, 0x92, 0x62, 0xbf, 0xdb, 0xff, 0x01, 0xeb, 0x7e, 0xed, 0x5d, 0xa6, 0x33, 0x84, 0xb6, 0xbb, + 0xc2, 0x79, 0x18, 0x47, 0xb7, 0xdb, 0xeb, 0x9d, 0xf1, 0x6b, 0x6d, 0x6b, 0xbf, 0xd7, 0xb6, 0xf6, + 0x67, 0x6d, 0x6b, 0x3f, 0xfe, 0xda, 0xff, 0x5d, 0xea, 0xe9, 0x6f, 0xf9, 0xe4, 0x5f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x75, 0xd0, 0x68, 0xcb, 0xa8, 0x05, 0x00, 0x00, +} + // Reference imports to suppress errors if they are not otherwise used. var _ context.Context var _ grpc.ClientConn @@ -1069,7 +1106,7 @@ var _CA_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "agent/connect/ca/plugin/provider.proto", + Metadata: "provider.proto", } func (m *ConfigureRequest) Marshal() (dAtA []byte, err error) { @@ -1691,7 +1728,7 @@ func (m *ConfigureRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1719,7 +1756,7 @@ func (m *ConfigureRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1729,6 +1766,9 @@ func (m *ConfigureRequest) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1748,7 +1788,7 @@ func (m *ConfigureRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= (int(b) & 0x7F) << shift + v |= int(b&0x7F) << shift if b < 0x80 { break } @@ -1768,7 +1808,7 @@ func (m *ConfigureRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } @@ -1777,6 +1817,9 @@ func (m *ConfigureRequest) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1794,6 +1837,9 @@ func (m *ConfigureRequest) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -1822,7 +1868,7 @@ func (m *SetIntermediateRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1850,7 +1896,7 @@ func (m *SetIntermediateRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1860,6 +1906,9 @@ func (m *SetIntermediateRequest) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1879,7 +1928,7 @@ func (m *SetIntermediateRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1889,6 +1938,9 @@ func (m *SetIntermediateRequest) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1903,6 +1955,9 @@ func (m *SetIntermediateRequest) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -1931,7 +1986,7 @@ func (m *SignRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1959,7 +2014,7 @@ func (m *SignRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } @@ -1968,6 +2023,9 @@ func (m *SignRequest) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1985,6 +2043,9 @@ func (m *SignRequest) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2013,7 +2074,7 @@ func (m *SignIntermediateRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2041,7 +2102,7 @@ func (m *SignIntermediateRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } @@ -2050,6 +2111,9 @@ func (m *SignIntermediateRequest) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -2067,6 +2131,9 @@ func (m *SignIntermediateRequest) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2095,7 +2162,7 @@ func (m *CrossSignCARequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2123,7 +2190,7 @@ func (m *CrossSignCARequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= (int(b) & 0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } @@ -2132,6 +2199,9 @@ func (m *CrossSignCARequest) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -2149,6 +2219,9 @@ func (m *CrossSignCARequest) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2177,7 +2250,7 @@ func (m *ActiveRootResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2205,7 +2278,7 @@ func (m *ActiveRootResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2215,6 +2288,9 @@ func (m *ActiveRootResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -2229,6 +2305,9 @@ func (m *ActiveRootResponse) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2257,7 +2336,7 @@ func (m *GenerateIntermediateCSRResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2285,7 +2364,7 @@ func (m *GenerateIntermediateCSRResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2295,6 +2374,9 @@ func (m *GenerateIntermediateCSRResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -2309,6 +2391,9 @@ func (m *GenerateIntermediateCSRResponse) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2337,7 +2422,7 @@ func (m *ActiveIntermediateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2365,7 +2450,7 @@ func (m *ActiveIntermediateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2375,6 +2460,9 @@ func (m *ActiveIntermediateResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -2389,6 +2477,9 @@ func (m *ActiveIntermediateResponse) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2417,7 +2508,7 @@ func (m *GenerateIntermediateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2445,7 +2536,7 @@ func (m *GenerateIntermediateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2455,6 +2546,9 @@ func (m *GenerateIntermediateResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -2469,6 +2563,9 @@ func (m *GenerateIntermediateResponse) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2497,7 +2594,7 @@ func (m *SignResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2525,7 +2622,7 @@ func (m *SignResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2535,6 +2632,9 @@ func (m *SignResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -2549,6 +2649,9 @@ func (m *SignResponse) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2577,7 +2680,7 @@ func (m *SignIntermediateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2605,7 +2708,7 @@ func (m *SignIntermediateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2615,6 +2718,9 @@ func (m *SignIntermediateResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -2629,6 +2735,9 @@ func (m *SignIntermediateResponse) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2657,7 +2766,7 @@ func (m *CrossSignCAResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2685,7 +2794,7 @@ func (m *CrossSignCAResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2695,6 +2804,9 @@ func (m *CrossSignCAResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthProvider } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -2709,6 +2821,9 @@ func (m *CrossSignCAResponse) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2737,7 +2852,7 @@ func (m *Empty) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2760,6 +2875,9 @@ func (m *Empty) Unmarshal(dAtA []byte) error { if skippy < 0 { return ErrInvalidLengthProvider } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProvider + } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } @@ -2827,10 +2945,13 @@ func skipProvider(dAtA []byte) (n int, err error) { break } } - iNdEx += length if length < 0 { return 0, ErrInvalidLengthProvider } + iNdEx += length + if iNdEx < 0 { + return 0, ErrInvalidLengthProvider + } return iNdEx, nil case 3: for { @@ -2859,6 +2980,9 @@ func skipProvider(dAtA []byte) (n int, err error) { return 0, err } iNdEx = start + next + if iNdEx < 0 { + return 0, ErrInvalidLengthProvider + } } return iNdEx, nil case 4: @@ -2877,47 +3001,3 @@ var ( ErrInvalidLengthProvider = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowProvider = fmt.Errorf("proto: integer overflow") ) - -func init() { - proto.RegisterFile("agent/connect/ca/plugin/provider.proto", fileDescriptor_provider_8ff2d2670790989c) -} - -var fileDescriptor_provider_8ff2d2670790989c = []byte{ - // 566 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xdf, 0x6e, 0xd3, 0x3e, - 0x18, 0xfd, 0xa5, 0xfb, 0xad, 0x5d, 0xbf, 0x15, 0xad, 0xf2, 0xa6, 0xb5, 0x14, 0x68, 0xab, 0x08, - 0xad, 0x45, 0x40, 0x23, 0x28, 0x68, 0x12, 0x57, 0x94, 0x68, 0x4c, 0x13, 0x37, 0x23, 0x15, 0x37, - 0x5c, 0x50, 0xa5, 0xae, 0x49, 0x2d, 0x35, 0x71, 0xb0, 0x9d, 0x49, 0xbc, 0x09, 0x6f, 0x04, 0x97, - 0x3c, 0x02, 0x2a, 0x2f, 0x82, 0x9c, 0x26, 0x59, 0x92, 0xa6, 0xcb, 0x5d, 0xfc, 0xe5, 0x9c, 0xf3, - 0xfd, 0x3b, 0x36, 0x9c, 0xd9, 0x0e, 0xf1, 0xa4, 0x81, 0x99, 0xe7, 0x11, 0x2c, 0x0d, 0x6c, 0x1b, - 0xfe, 0x2a, 0x70, 0xa8, 0x67, 0xf8, 0x9c, 0xdd, 0xd0, 0x05, 0xe1, 0x23, 0x9f, 0x33, 0xc9, 0x50, - 0x75, 0x13, 0xd6, 0xe7, 0xd0, 0x34, 0x99, 0xf7, 0x95, 0x3a, 0x01, 0x27, 0x16, 0xf9, 0x16, 0x10, - 0x21, 0xd1, 0x23, 0x00, 0xbc, 0x0a, 0x84, 0x24, 0x7c, 0x46, 0x17, 0x6d, 0xad, 0xaf, 0x0d, 0xeb, - 0x56, 0x3d, 0x8a, 0x5c, 0x2d, 0x50, 0x0b, 0x6a, 0x54, 0xcc, 0x38, 0x63, 0xb2, 0x5d, 0xe9, 0x6b, - 0xc3, 0x03, 0xab, 0x4a, 0x85, 0xc5, 0x98, 0x44, 0xa7, 0x50, 0xc5, 0xa1, 0x56, 0x7b, 0xaf, 0xaf, - 0x0d, 0x1b, 0x56, 0x74, 0xd2, 0xbf, 0xc0, 0xe9, 0x94, 0xc8, 0x2b, 0x4f, 0x12, 0xee, 0x92, 0x05, - 0xb5, 0x65, 0x92, 0xe9, 0x09, 0x34, 0x69, 0x2a, 0x3c, 0xf3, 0x89, 0x1b, 0xe5, 0x3b, 0x4a, 0xc7, - 0xaf, 0x89, 0x8b, 0xee, 0xc3, 0x81, 0x4a, 0x19, 0x42, 0x2a, 0x21, 0xa4, 0xa6, 0xce, 0xd7, 0xc4, - 0xd5, 0x7b, 0x70, 0x38, 0xa5, 0x8e, 0x17, 0x8b, 0x36, 0x61, 0x0f, 0x0b, 0x1e, 0xea, 0x34, 0x2c, - 0xf5, 0xa9, 0x3f, 0x85, 0x96, 0x02, 0x14, 0x55, 0xb0, 0x0d, 0x3e, 0x03, 0x64, 0x72, 0x26, 0x84, - 0x62, 0x98, 0x93, 0x34, 0x8e, 0xcb, 0x04, 0xc7, 0xa5, 0xfe, 0x1c, 0xd0, 0x04, 0x4b, 0x7a, 0x43, - 0x54, 0xef, 0x16, 0x11, 0x3e, 0xf3, 0x04, 0x51, 0xc3, 0xc1, 0x5c, 0xa6, 0x1a, 0xa9, 0x62, 0x1e, - 0x16, 0xf9, 0x06, 0x7a, 0x97, 0xc4, 0x23, 0xdc, 0x96, 0x24, 0x5d, 0x87, 0x39, 0xb5, 0x32, 0x5c, - 0xc1, 0x33, 0x5c, 0xc1, 0x15, 0xf7, 0x35, 0x74, 0x36, 0xa9, 0xb2, 0x1d, 0x94, 0xa5, 0x3c, 0x87, - 0x87, 0x45, 0x29, 0xcb, 0x89, 0x03, 0x68, 0x6c, 0x06, 0x5a, 0x06, 0x1c, 0x43, 0x7b, 0x7b, 0xb0, - 0x65, 0xa4, 0x11, 0x1c, 0x67, 0x06, 0x5c, 0x86, 0xaf, 0xc1, 0xfe, 0x85, 0xeb, 0xcb, 0xef, 0x2f, - 0x7f, 0xee, 0x43, 0xc5, 0x9c, 0xa0, 0x57, 0x50, 0x4f, 0x2c, 0x8b, 0xda, 0xa3, 0x8d, 0x91, 0x47, - 0x79, 0x17, 0x77, 0xee, 0xc5, 0x7f, 0x42, 0x32, 0x7a, 0x06, 0x8d, 0x78, 0x18, 0xa1, 0x59, 0xb3, - 0xbf, 0xf3, 0xe8, 0x73, 0x80, 0xdb, 0xe5, 0xe6, 0xb1, 0x9d, 0xf8, 0x58, 0xb0, 0xff, 0x8f, 0xd0, - 0xda, 0xb1, 0xe6, 0xbc, 0xca, 0x20, 0x3e, 0x96, 0xd9, 0xe2, 0x2d, 0x1c, 0xe5, 0xae, 0x0f, 0xea, - 0xc6, 0xdc, 0xe2, 0x7b, 0x95, 0xef, 0xe6, 0x32, 0xb6, 0x6a, 0x46, 0x24, 0x57, 0x8f, 0x9e, 0xed, - 0xaa, 0x70, 0xa7, 0x1f, 0xe0, 0xa4, 0xa8, 0xda, 0xbc, 0xd4, 0xe3, 0xbb, 0x5a, 0x4b, 0xc4, 0x5e, - 0xc0, 0xff, 0xca, 0x02, 0xe8, 0x38, 0x69, 0xe6, 0xf6, 0x12, 0x77, 0x4e, 0xb2, 0xc1, 0x88, 0xf2, - 0x09, 0x9a, 0x79, 0xbf, 0xa1, 0x5e, 0x1a, 0x59, 0x34, 0x8c, 0xfe, 0x6e, 0x40, 0x24, 0xfb, 0x1e, - 0x0e, 0x53, 0x8e, 0x44, 0xc9, 0x7e, 0xb7, 0xdf, 0x81, 0xce, 0x83, 0xc2, 0x7f, 0x91, 0xce, 0x00, - 0x6a, 0xe6, 0x8a, 0xd8, 0x5e, 0xe0, 0xdf, 0x6d, 0xaf, 0x77, 0x17, 0xbf, 0xd6, 0x5d, 0xed, 0xf7, - 0xba, 0xab, 0xfd, 0x59, 0x77, 0xb5, 0x1f, 0x7f, 0xbb, 0xff, 0x7d, 0x1e, 0x3b, 0x54, 0x2e, 0x83, - 0xf9, 0x08, 0x33, 0xd7, 0x58, 0xda, 0x62, 0x49, 0x31, 0xe3, 0xbe, 0x7a, 0xc6, 0x45, 0xb0, 0x32, - 0x76, 0xbc, 0xe9, 0xf3, 0x6a, 0xf8, 0x96, 0x8f, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x20, - 0xb4, 0xe4, 0xf5, 0x05, 0x00, 0x00, -} diff --git a/agent/connect/ca/plugin/provider.proto b/agent/connect/ca/plugin/provider.proto index 6ca9cf88f5..bc0d9aa785 100644 --- a/agent/connect/ca/plugin/provider.proto +++ b/agent/connect/ca/plugin/provider.proto @@ -10,8 +10,6 @@ syntax = "proto3"; -option go_package = "github.com/hashicorp/consul/agent/connect/ca/plugin"; - package plugin; service CA { diff --git a/agent/consul/rpc.go b/agent/consul/rpc.go index 1ebac8d7eb..fd1ce3cb2a 100644 --- a/agent/consul/rpc.go +++ b/agent/consul/rpc.go @@ -10,6 +10,7 @@ import ( "time" "github.com/armon/go-metrics" + "github.com/hashicorp/consul/agent/agentpb" "github.com/hashicorp/consul/agent/consul/state" "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/pool" @@ -370,10 +371,34 @@ func (s *Server) globalRPC(method string, args interface{}, return nil } +type raftEncoder func(structs.MessageType, interface{}) ([]byte, error) + // raftApply is used to encode a message, run it through raft, and return // the FSM response along with any errors func (s *Server) raftApply(t structs.MessageType, msg interface{}) (interface{}, error) { - buf, err := structs.Encode(t, msg) + return s.raftApplyMsgpack(t, msg) +} + +// raftApplyMsgpack will msgpack encode the request and then run it through raft, +// then return the FSM response along with any errors. +func (s *Server) raftApplyMsgpack(t structs.MessageType, msg interface{}) (interface{}, error) { + return s.raftApplyWithEncoder(t, msg, structs.Encode) +} + +// raftApplyProtobuf will protobuf encode the request and then run it through raft, +// then return the FSM response along with any errors. +func (s *Server) raftApplyProtobuf(t structs.MessageType, msg interface{}) (interface{}, error) { + return s.raftApplyWithEncoder(t, msg, agentpb.EncodeInterface) +} + +// raftApplyWithEncoder is used to encode a message, run it through raft, +// and return the FSM response along with any errors. Unlike raftApply this +// takes the encoder to use as an argument. +func (s *Server) raftApplyWithEncoder(t structs.MessageType, msg interface{}, encoder raftEncoder) (interface{}, error) { + if encoder == nil { + return nil, fmt.Errorf("Failed to encode request: nil encoder") + } + buf, err := encoder(t, msg) if err != nil { return nil, fmt.Errorf("Failed to encode request: %v", err) } @@ -429,28 +454,47 @@ func (s *Server) raftApply(t structs.MessageType, msg interface{}) (interface{}, // a snapshot. type queryFn func(memdb.WatchSet, *state.Store) error +// we specify this as an interface so that we can allow a our legacy structs.QueryOptions +// and the protobuf defined QueryOptions struct to both be used here. +type queryOptions interface { + GetMinQueryIndex() uint64 + GetMaxQueryTime() time.Duration + GetRequireConsistent() bool +} + +// we specify this as an interface so that we can allow a our legacy structs.QueryMeta +// and the protobuf defined QueryMeta struct to both be used here. +type queryMeta interface { + SetLastContact(time.Duration) + SetKnownLeader(bool) + GetIndex() uint64 + SetIndex(uint64) +} + // blockingQuery is used to process a potentially blocking query operation. -func (s *Server) blockingQuery(queryOpts *structs.QueryOptions, queryMeta *structs.QueryMeta, - fn queryFn) error { +func (s *Server) blockingQuery(queryOpts queryOptions, queryMeta queryMeta, fn queryFn) error { var timeout *time.Timer + var queryTimeout time.Duration + minQueryIndex := queryOpts.GetMinQueryIndex() // Fast path right to the non-blocking query. - if queryOpts.MinQueryIndex == 0 { + if minQueryIndex == 0 { goto RUN_QUERY } + queryTimeout = queryOpts.GetMaxQueryTime() // Restrict the max query time, and ensure there is always one. - if queryOpts.MaxQueryTime > maxQueryTime { - queryOpts.MaxQueryTime = maxQueryTime - } else if queryOpts.MaxQueryTime <= 0 { - queryOpts.MaxQueryTime = defaultQueryTime + if queryTimeout > maxQueryTime { + queryTimeout = maxQueryTime + } else if queryTimeout <= 0 { + queryTimeout = defaultQueryTime } // Apply a small amount of jitter to the request. - queryOpts.MaxQueryTime += lib.RandomStagger(queryOpts.MaxQueryTime / jitterFraction) + queryTimeout += lib.RandomStagger(queryTimeout / jitterFraction) // Setup a query timeout. - timeout = time.NewTimer(queryOpts.MaxQueryTime) + timeout = time.NewTimer(queryTimeout) defer timeout.Stop() RUN_QUERY: @@ -458,7 +502,7 @@ RUN_QUERY: s.setQueryMeta(queryMeta) // If the read must be consistent we verify that we are still the leader. - if queryOpts.RequireConsistent { + if queryOpts.GetRequireConsistent() { if err := s.consistentRead(); err != nil { return err } @@ -474,7 +518,7 @@ RUN_QUERY: // We can skip all watch tracking if this isn't a blocking query. var ws memdb.WatchSet - if queryOpts.MinQueryIndex > 0 { + if minQueryIndex > 0 { ws = memdb.NewWatchSet() // This channel will be closed if a snapshot is restored and the @@ -492,10 +536,10 @@ RUN_QUERY: // state method). We also need to ensure that unless there is an error, we // return an index > 0 otherwise the client will never block and burn CPU and // requests. - if err == nil && queryMeta.Index < 1 { - queryMeta.Index = 1 + if err == nil && queryMeta.GetIndex() < 1 { + queryMeta.SetIndex(1) } - if err == nil && queryOpts.MinQueryIndex > 0 && queryMeta.Index <= queryOpts.MinQueryIndex { + if err == nil && minQueryIndex > 0 && queryMeta.GetIndex() <= minQueryIndex { if expired := ws.Watch(timeout.C); !expired { // If a restore may have woken us up then bail out from // the query immediately. This is slightly race-ey since @@ -513,13 +557,13 @@ RUN_QUERY: } // setQueryMeta is used to populate the QueryMeta data for an RPC call -func (s *Server) setQueryMeta(m *structs.QueryMeta) { +func (s *Server) setQueryMeta(m queryMeta) { if s.IsLeader() { - m.LastContact = 0 - m.KnownLeader = true + m.SetLastContact(0) + m.SetKnownLeader(true) } else { - m.LastContact = time.Since(s.raft.LastContact()) - m.KnownLeader = (s.raft.Leader() != "") + m.SetLastContact(time.Since(s.raft.LastContact())) + m.SetKnownLeader(s.raft.Leader() != "") } } diff --git a/agent/consul/state/acl.go b/agent/consul/state/acl.go index cdc24d6cd6..88cdbeec6a 100644 --- a/agent/consul/state/acl.go +++ b/agent/consul/state/acl.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/hashicorp/consul/agent/agentpb" "github.com/hashicorp/consul/agent/structs" memdb "github.com/hashicorp/go-memdb" ) @@ -560,6 +561,79 @@ func (s *Store) CanBootstrapACLToken() (bool, uint64, error) { return false, out.(*IndexEntry).Value, nil } +// resolveACLLinks is used to populate the links Name given its ID as the object is inserted +// into the Store. This will modify the links in place and should not be performed on data +// already inserted into the store without copying first. This is an optimization so that when +// the link is read back out of the Store, we hopefully will not have to copy the object being retrieved +// to update the name. Unlike the older functions to operate specifically on role or policy links +// this function does not itself handle the case where the id cannot be found. Instead the +// getName function should handle that and return an error if necessary +func (s *Store) resolveACLLinks(tx *memdb.Txn, links []agentpb.ACLLink, getName func(*memdb.Txn, string) (string, error)) (int, error) { + var numValid int + for linkIndex, link := range links { + if link.ID != "" { + name, err := getName(tx, link.ID) + + if err != nil { + return 0, err + } + + // the name doesn't matter here + if name != "" { + links[linkIndex].Name = name + numValid++ + } + } else { + return 0, fmt.Errorf("Encountered an ACL resource linked by Name in the state store") + } + } + return numValid, nil +} + +// fixupACLLinks is used to ensure data returned by read operations have the most up to date name +// associated with the ID of the link. Ideally this will be a no-op if the names are already correct +// however if a linked resource was renamed it might be stale. This function will treat the incoming +// links with copy-on-write semantics and its output will indicate whether any modifications were made. +func (s *Store) fixupACLLinks(tx *memdb.Txn, original []agentpb.ACLLink, getName func(*memdb.Txn, string) (string, error)) ([]agentpb.ACLLink, bool, error) { + owned := false + links := original + + cloneLinks := func(l []agentpb.ACLLink, copyNumLinks int) []agentpb.ACLLink { + clone := make([]agentpb.ACLLink, copyNumLinks) + copy(clone, l[:copyNumLinks]) + return clone + } + + for linkIndex, link := range original { + name, err := getName(tx, link.ID) + + if err != nil { + return nil, false, err + } + + if name == "" { + if !owned { + // clone the original as we cannot modify anything stored in memdb + links = cloneLinks(original, linkIndex) + owned = true + } + // if already owned then we just don't append it. + } else if name != link.Name { + if !owned { + links = cloneLinks(original, linkIndex) + owned = true + } + + // append the corrected link + links = append(links, agentpb.ACLLink{ID: link.ID, Name: name}) + } else if owned { + links = append(links, link) + } + } + + return links, owned, nil +} + func (s *Store) resolveTokenPolicyLinks(tx *memdb.Txn, token *structs.ACLToken, allowMissing bool) (int, error) { var numValid int for linkIndex, link := range token.Policies { diff --git a/agent/consul/state/acl_test.go b/agent/consul/state/acl_test.go index 563f6bde08..6057b337dc 100644 --- a/agent/consul/state/acl_test.go +++ b/agent/consul/state/acl_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/hashicorp/consul/acl" + "github.com/hashicorp/consul/agent/agentpb" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" memdb "github.com/hashicorp/go-memdb" @@ -4062,3 +4063,210 @@ func TestStateStore_ACLBindingRules_Snapshot_Restore(t *testing.T) { require.Equal(t, uint64(2), s.maxIndex("acl-binding-rules")) }() } + +func TestStateStore_resolveACLLinks(t *testing.T) { + t.Parallel() + + t.Run("missing link id", func(t *testing.T) { + t.Parallel() + s := testStateStore(t) + + tx := s.db.Txn(false) + defer tx.Abort() + + links := []agentpb.ACLLink{ + agentpb.ACLLink{ + Name: "foo", + }, + } + + _, err := s.resolveACLLinks(tx, links, func(*memdb.Txn, string) (string, error) { + err := fmt.Errorf("Should not be attempting to resolve an empty id") + require.Fail(t, err.Error()) + return "", err + }) + + require.Error(t, err) + require.Contains(t, err.Error(), "Encountered an ACL resource linked by Name in the state store") + }) + + t.Run("typical", func(t *testing.T) { + t.Parallel() + s := testStateStore(t) + + tx := s.db.Txn(false) + defer tx.Abort() + + links := []agentpb.ACLLink{ + agentpb.ACLLink{ + ID: "b985e082-25d3-45a9-9dd8-fd1a41b83b0d", + }, + agentpb.ACLLink{ + ID: "e81887b4-836b-4053-a1fa-7e8305902be9", + }, + } + + numValid, err := s.resolveACLLinks(tx, links, func(_ *memdb.Txn, linkID string) (string, error) { + switch linkID { + case "e81887b4-836b-4053-a1fa-7e8305902be9": + return "foo", nil + case "b985e082-25d3-45a9-9dd8-fd1a41b83b0d": + return "bar", nil + default: + return "", fmt.Errorf("No such id") + } + }) + + require.NoError(t, err) + require.Equal(t, "bar", links[0].Name) + require.Equal(t, "foo", links[1].Name) + require.Equal(t, 2, numValid) + }) + + t.Run("unresolvable", func(t *testing.T) { + t.Parallel() + s := testStateStore(t) + + tx := s.db.Txn(false) + defer tx.Abort() + + links := []agentpb.ACLLink{ + agentpb.ACLLink{ + ID: "b985e082-25d3-45a9-9dd8-fd1a41b83b0d", + }, + } + + numValid, err := s.resolveACLLinks(tx, links, func(_ *memdb.Txn, linkID string) (string, error) { + require.Equal(t, "b985e082-25d3-45a9-9dd8-fd1a41b83b0d", linkID) + return "", nil + }) + + require.NoError(t, err) + require.Empty(t, links[0].Name) + require.Equal(t, 0, numValid) + }) +} + +func TestStateStore_fixupACLLinks(t *testing.T) { + t.Parallel() + + links := []agentpb.ACLLink{ + agentpb.ACLLink{ + ID: "40b57f86-97ea-40e4-a99a-c399cc81f4dd", + Name: "foo", + }, + agentpb.ACLLink{ + ID: "8f024f92-1f8e-42ea-a3c3-55fb0c8670bc", + Name: "bar", + }, + agentpb.ACLLink{ + ID: "c91afed1-e474-4cd2-98aa-cd57dd9377e9", + Name: "baz", + }, + agentpb.ACLLink{ + ID: "c1585be7-ab0e-4973-b572-ba9afda86e07", + Name: "four", + }, + } + + t.Run("unaltered", func(t *testing.T) { + t.Parallel() + s := testStateStore(t) + + tx := s.db.Txn(false) + defer tx.Abort() + + newLinks, cloned, err := s.fixupACLLinks(tx, links, func(_ *memdb.Txn, linkID string) (string, error) { + switch linkID { + case "40b57f86-97ea-40e4-a99a-c399cc81f4dd": + return "foo", nil + case "8f024f92-1f8e-42ea-a3c3-55fb0c8670bc": + return "bar", nil + case "c91afed1-e474-4cd2-98aa-cd57dd9377e9": + return "baz", nil + case "c1585be7-ab0e-4973-b572-ba9afda86e07": + return "four", nil + default: + return "", nil + } + }) + + require.NoError(t, err) + require.False(t, cloned) + require.Equal(t, links, newLinks) + }) + + t.Run("renamed", func(t *testing.T) { + t.Parallel() + s := testStateStore(t) + + tx := s.db.Txn(false) + defer tx.Abort() + + newLinks, cloned, err := s.fixupACLLinks(tx, links, func(_ *memdb.Txn, linkID string) (string, error) { + switch linkID { + case "40b57f86-97ea-40e4-a99a-c399cc81f4dd": + return "foo", nil + case "8f024f92-1f8e-42ea-a3c3-55fb0c8670bc": + return "bart", nil + case "c91afed1-e474-4cd2-98aa-cd57dd9377e9": + return "bazzy", nil + case "c1585be7-ab0e-4973-b572-ba9afda86e07": + return "four", nil + default: + return "", nil + } + }) + + require.NoError(t, err) + require.True(t, cloned) + require.Equal(t, links[0], newLinks[0]) + require.Equal(t, links[1].ID, newLinks[1].ID) + require.Equal(t, "bart", newLinks[1].Name) + require.Equal(t, links[2].ID, newLinks[2].ID) + require.Equal(t, "bazzy", newLinks[2].Name) + require.Equal(t, links[3], newLinks[3]) + }) + + t.Run("deleted", func(t *testing.T) { + t.Parallel() + s := testStateStore(t) + + tx := s.db.Txn(false) + defer tx.Abort() + + newLinks, cloned, err := s.fixupACLLinks(tx, links, func(_ *memdb.Txn, linkID string) (string, error) { + switch linkID { + case "40b57f86-97ea-40e4-a99a-c399cc81f4dd": + return "foo", nil + case "c91afed1-e474-4cd2-98aa-cd57dd9377e9": + return "baz", nil + case "c1585be7-ab0e-4973-b572-ba9afda86e07": + return "four", nil + default: + return "", nil + } + }) + + require.NoError(t, err) + require.True(t, cloned) + require.Equal(t, links[0], newLinks[0]) + require.Equal(t, links[2], newLinks[1]) + require.Equal(t, links[3], newLinks[2]) + }) + + t.Run("error", func(t *testing.T) { + t.Parallel() + s := testStateStore(t) + + tx := s.db.Txn(false) + defer tx.Abort() + + _, _, err := s.fixupACLLinks(tx, links, func(*memdb.Txn, string) (string, error) { + return "", fmt.Errorf("Resolver Error") + }) + + require.Error(t, err) + require.Equal(t, err.Error(), "Resolver Error") + }) +} diff --git a/agent/structs/structs.go b/agent/structs/structs.go index 166c41bbb8..3e3a012632 100644 --- a/agent/structs/structs.go +++ b/agent/structs/structs.go @@ -203,6 +203,18 @@ func (q QueryOptions) TokenSecret() string { return q.Token } +func (q QueryOptions) GetMinQueryIndex() uint64 { + return q.MinQueryIndex +} + +func (q QueryOptions) GetMaxQueryTime() time.Duration { + return q.MaxQueryTime +} + +func (q QueryOptions) GetRequireConsistent() bool { + return q.RequireConsistent +} + type WriteRequest struct { // Token is the ACL token ID. If not provided, the 'anonymous' // token is assumed for backwards compatibility. @@ -242,6 +254,22 @@ type QueryMeta struct { ConsistencyLevel string } +func (q *QueryMeta) SetLastContact(lastContact time.Duration) { + q.LastContact = lastContact +} + +func (q *QueryMeta) SetKnownLeader(knownLeader bool) { + q.KnownLeader = knownLeader +} + +func (q *QueryMeta) GetIndex() uint64 { + return q.Index +} + +func (q *QueryMeta) SetIndex(index uint64) { + q.Index = index +} + // RegisterRequest is used for the Catalog.Register endpoint // to register a node as providing a service. If no service // is provided, the node is registered. diff --git a/build-support/functions/10-util.sh b/build-support/functions/10-util.sh index 97463804be..240d210361 100644 --- a/build-support/functions/10-util.sh +++ b/build-support/functions/10-util.sh @@ -58,6 +58,12 @@ function debug { fi } +function debug_run { + debug "$@" + $@ + return $? +} + function sed_i { if test "$(uname)" == "Darwin" then diff --git a/build-support/scripts/proto-gen.sh b/build-support/scripts/proto-gen.sh new file mode 100755 index 0000000000..928312bd64 --- /dev/null +++ b/build-support/scripts/proto-gen.sh @@ -0,0 +1,141 @@ +#!/bin/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: + This script will build generate the Go files from protobuf files. In addition to + just running the correct protoc generator it will also fixup build tags in the + generated code. + +Options: + --import-replace Replace imports of google types with those from the gogo/protobuf repo. + + --generator Which generator to use: gogo, gofast etc. Defaults to gofast. + + --grpc Enable the gRPC plugin + + -h | --help Print this help text. +EOF +} + +function err_usage { + err "$1" + err "" + err "$(usage)" +} + +function main { + local generator=gofast + 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 + ;; + generator ) + if test -z "$2" + then + err_usage "ERROR: option -g/--generator requires an argument" + return 1 + fi + + generator="$2" + shift 2 + ;; + --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 + + 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}") + + 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/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" + + local proto_go_path=${proto_path%%.proto}.pb.go + + local go_proto_out="" + local sep="" + if is_set "${grpc}" + then + go_proto_out="plugins=grpc" + sep="," + fi + + if is_set "${imp_replace}" + then + go_proto_out="${go_proto_out}${sep}${gogo_proto_imp_replace}" + fi + + if test -n "${go_proto_out}" + then + go_proto_out="${go_proto_out}:" + fi + + local -i ret=0 + status_stage "Generating ${proto_go_path} from ${proto_path}" + debug_run protoc \ + -I="$(dirname ${proto_path})" \ + -I="${gogo_proto_path}/protobuf" \ + -I="${gogo_proto_path}" \ + -I="${gogo_proto_mod_path}" \ + --${generator}_out="${go_proto_out}$(dirname ${proto_path})" \ + "${proto_path}" + if test $? -ne 0 + then + err "Failed to generate ${proto_go_path} from ${proto_path}" + return 1 + fi + + 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}" + fi + + return 0 +} + +main "$@" +exit $? diff --git a/vendor/modules.txt b/vendor/modules.txt index 184260d494..703e89bafc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -149,12 +149,12 @@ github.com/gocql/gocql/internal/streams github.com/gogo/googleapis/google/rpc github.com/gogo/googleapis/google/api # github.com/gogo/protobuf v1.2.1 +github.com/gogo/protobuf/gogoproto +github.com/gogo/protobuf/types github.com/gogo/protobuf/jsonpb github.com/gogo/protobuf/proto -github.com/gogo/protobuf/types -github.com/gogo/protobuf/sortkeys -github.com/gogo/protobuf/gogoproto github.com/gogo/protobuf/protoc-gen-gogo/descriptor +github.com/gogo/protobuf/sortkeys # github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/glog # github.com/golang/protobuf v1.3.1