Add support for implementing new requests with protobufs instea… (#6502)

* 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=<list of proto files to rebuild>

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
pull/6516/head
Matt Keeler 5 years ago committed by GitHub
parent 9f4ecdbf3e
commit 51dcd126b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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")
)

@ -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\""];
}

@ -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
}

File diff suppressed because it is too large Load Diff

@ -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;
}

@ -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)
}

@ -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, 0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x4e, 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, 0x9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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,
}

@ -10,8 +10,6 @@
syntax = "proto3";
option go_package = "github.com/hashicorp/consul/agent/connect/ca/plugin";
package plugin;
service CA {

@ -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() != "")
}
}

@ -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 {

@ -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")
})
}

@ -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.

@ -58,6 +58,12 @@ function debug {
fi
}
function debug_run {
debug "$@"
$@
return $?
}
function sed_i {
if test "$(uname)" == "Darwin"
then

@ -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} [<options ...>] <proto filepath>
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 $?

@ -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

Loading…
Cancel
Save