remove gogo from pbservice
This commit is contained in:
parent
807a399b97
commit
98b733e41a
|
@ -16,7 +16,7 @@ type registry struct {
|
|||
byAuthority map[string]*ServerResolverBuilder
|
||||
}
|
||||
|
||||
func (r *registry) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOption) (resolver.Resolver, error) {
|
||||
func (r *registry) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
|
||||
r.lock.RLock()
|
||||
defer r.lock.RUnlock()
|
||||
res, ok := r.byAuthority[target.Authority]
|
||||
|
|
|
@ -85,7 +85,7 @@ func (s *ServerResolverBuilder) ServerForGlobalAddr(globalAddr string) (*metadat
|
|||
|
||||
// Build returns a new serverResolver for the given ClientConn. The resolver
|
||||
// will keep the ClientConn's state updated based on updates from Serf.
|
||||
func (s *ServerResolverBuilder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOption) (resolver.Resolver, error) {
|
||||
func (s *ServerResolverBuilder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
|
@ -221,7 +221,6 @@ func (s *ServerResolverBuilder) getDCAddrs(dc string) []resolver.Address {
|
|||
addrs = append(addrs, resolver.Address{
|
||||
// NOTE: the address persisted here is only dialable using our custom dialer
|
||||
Addr: DCPrefix(server.Datacenter, server.Addr.String()),
|
||||
Type: resolver.Backend,
|
||||
ServerName: server.Name,
|
||||
})
|
||||
}
|
||||
|
@ -294,14 +293,14 @@ func (r *serverResolver) Close() {
|
|||
}
|
||||
|
||||
// ResolveNow is not used
|
||||
func (*serverResolver) ResolveNow(resolver.ResolveNowOption) {}
|
||||
func (*serverResolver) ResolveNow(options resolver.ResolveNowOptions) {}
|
||||
|
||||
type leaderResolver struct {
|
||||
globalAddr string
|
||||
clientConn resolver.ClientConn
|
||||
}
|
||||
|
||||
func (l leaderResolver) ResolveNow(resolver.ResolveNowOption) {}
|
||||
func (l leaderResolver) ResolveNow(resolver.ResolveNowOptions) {}
|
||||
|
||||
func (l leaderResolver) Close() {}
|
||||
|
||||
|
@ -313,7 +312,6 @@ func (l leaderResolver) updateClientConn() {
|
|||
{
|
||||
// NOTE: the address persisted here is only dialable using our custom dialer
|
||||
Addr: l.globalAddr,
|
||||
Type: resolver.Backend,
|
||||
ServerName: "leader",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package subscribe
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/golang/protobuf/ptypes/duration"
|
||||
"github.com/hashicorp/consul/proto/pbcommon"
|
||||
"io"
|
||||
"net"
|
||||
"testing"
|
||||
|
@ -154,12 +156,14 @@ func TestServer_Subscribe_IntegrationWithBackend(t *testing.T) {
|
|||
Port: 8080,
|
||||
Weights: &pbservice.Weights{Passing: 1, Warning: 1},
|
||||
// Sad empty state
|
||||
Proxy: pbservice.ConnectProxyConfig{
|
||||
MeshGateway: pbservice.MeshGatewayConfig{},
|
||||
Expose: pbservice.ExposeConfig{},
|
||||
Proxy: &pbservice.ConnectProxyConfig{
|
||||
MeshGateway: &pbservice.MeshGatewayConfig{},
|
||||
Expose: &pbservice.ExposeConfig{},
|
||||
TransparentProxy: &pbservice.TransparentProxyConfig{},
|
||||
},
|
||||
Connect: &pbservice.ServiceConnect{},
|
||||
RaftIndex: raftIndex(ids, "reg2", "reg2"),
|
||||
EnterpriseMeta: pbcommongogo.DefaultEnterpriseMeta,
|
||||
EnterpriseMeta: pbcommon.DefaultEnterpriseMeta,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -185,12 +189,14 @@ func TestServer_Subscribe_IntegrationWithBackend(t *testing.T) {
|
|||
Port: 8080,
|
||||
Weights: &pbservice.Weights{Passing: 1, Warning: 1},
|
||||
// Sad empty state
|
||||
Proxy: pbservice.ConnectProxyConfig{
|
||||
MeshGateway: pbservice.MeshGatewayConfig{},
|
||||
Expose: pbservice.ExposeConfig{},
|
||||
Proxy: &pbservice.ConnectProxyConfig{
|
||||
MeshGateway: &pbservice.MeshGatewayConfig{},
|
||||
Expose: &pbservice.ExposeConfig{},
|
||||
TransparentProxy: &pbservice.TransparentProxyConfig{},
|
||||
},
|
||||
Connect: &pbservice.ServiceConnect{},
|
||||
RaftIndex: raftIndex(ids, "reg3", "reg3"),
|
||||
EnterpriseMeta: pbcommongogo.DefaultEnterpriseMeta,
|
||||
EnterpriseMeta: pbcommon.DefaultEnterpriseMeta,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -235,12 +241,14 @@ func TestServer_Subscribe_IntegrationWithBackend(t *testing.T) {
|
|||
Port: 8080,
|
||||
Weights: &pbservice.Weights{Passing: 1, Warning: 1},
|
||||
// Sad empty state
|
||||
Proxy: pbservice.ConnectProxyConfig{
|
||||
MeshGateway: pbservice.MeshGatewayConfig{},
|
||||
Expose: pbservice.ExposeConfig{},
|
||||
Proxy: &pbservice.ConnectProxyConfig{
|
||||
MeshGateway: &pbservice.MeshGatewayConfig{},
|
||||
Expose: &pbservice.ExposeConfig{},
|
||||
TransparentProxy: &pbservice.TransparentProxyConfig{},
|
||||
},
|
||||
Connect: &pbservice.ServiceConnect{},
|
||||
RaftIndex: raftIndex(ids, "reg3", "reg3"),
|
||||
EnterpriseMeta: pbcommongogo.DefaultEnterpriseMeta,
|
||||
EnterpriseMeta: pbcommon.DefaultEnterpriseMeta,
|
||||
},
|
||||
Checks: []*pbservice.HealthCheck{
|
||||
{
|
||||
|
@ -251,7 +259,13 @@ func TestServer_Subscribe_IntegrationWithBackend(t *testing.T) {
|
|||
ServiceID: "redis1",
|
||||
ServiceName: "redis",
|
||||
RaftIndex: raftIndex(ids, "update", "update"),
|
||||
EnterpriseMeta: pbcommongogo.DefaultEnterpriseMeta,
|
||||
EnterpriseMeta: pbcommon.DefaultEnterpriseMeta,
|
||||
Definition: &pbservice.HealthCheckDefinition{
|
||||
Interval: &duration.Duration{},
|
||||
Timeout: &duration.Duration{},
|
||||
DeregisterCriticalServiceAfter: &duration.Duration{},
|
||||
TTL: &duration.Duration{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -395,8 +409,8 @@ func newCounter() *counter {
|
|||
return &counter{labels: make(map[string]uint64)}
|
||||
}
|
||||
|
||||
func raftIndex(ids *counter, created, modified string) pbcommongogo.RaftIndex {
|
||||
return pbcommongogo.RaftIndex{
|
||||
func raftIndex(ids *counter, created, modified string) *pbcommon.RaftIndex {
|
||||
return &pbcommon.RaftIndex{
|
||||
CreateIndex: ids.For(created),
|
||||
ModifyIndex: ids.For(modified),
|
||||
}
|
||||
|
@ -507,11 +521,13 @@ func TestServer_Subscribe_IntegrationWithBackend_ForwardToDC(t *testing.T) {
|
|||
Port: 8080,
|
||||
Weights: &pbservice.Weights{Passing: 1, Warning: 1},
|
||||
// Sad empty state
|
||||
Proxy: pbservice.ConnectProxyConfig{
|
||||
MeshGateway: pbservice.MeshGatewayConfig{},
|
||||
Expose: pbservice.ExposeConfig{},
|
||||
Proxy: &pbservice.ConnectProxyConfig{
|
||||
MeshGateway: &pbservice.MeshGatewayConfig{},
|
||||
Expose: &pbservice.ExposeConfig{},
|
||||
TransparentProxy: &pbservice.TransparentProxyConfig{},
|
||||
},
|
||||
EnterpriseMeta: pbcommongogo.DefaultEnterpriseMeta,
|
||||
Connect: &pbservice.ServiceConnect{},
|
||||
EnterpriseMeta: pbcommon.DefaultEnterpriseMeta,
|
||||
RaftIndex: raftIndex(ids, "reg2", "reg2"),
|
||||
},
|
||||
},
|
||||
|
@ -538,11 +554,13 @@ func TestServer_Subscribe_IntegrationWithBackend_ForwardToDC(t *testing.T) {
|
|||
Port: 8080,
|
||||
Weights: &pbservice.Weights{Passing: 1, Warning: 1},
|
||||
// Sad empty state
|
||||
Proxy: pbservice.ConnectProxyConfig{
|
||||
MeshGateway: pbservice.MeshGatewayConfig{},
|
||||
Expose: pbservice.ExposeConfig{},
|
||||
Proxy: &pbservice.ConnectProxyConfig{
|
||||
MeshGateway: &pbservice.MeshGatewayConfig{},
|
||||
Expose: &pbservice.ExposeConfig{},
|
||||
TransparentProxy: &pbservice.TransparentProxyConfig{},
|
||||
},
|
||||
EnterpriseMeta: pbcommongogo.DefaultEnterpriseMeta,
|
||||
Connect: &pbservice.ServiceConnect{},
|
||||
EnterpriseMeta: pbcommon.DefaultEnterpriseMeta,
|
||||
RaftIndex: raftIndex(ids, "reg3", "reg3"),
|
||||
},
|
||||
},
|
||||
|
@ -589,11 +607,13 @@ func TestServer_Subscribe_IntegrationWithBackend_ForwardToDC(t *testing.T) {
|
|||
RaftIndex: raftIndex(ids, "reg3", "reg3"),
|
||||
Weights: &pbservice.Weights{Passing: 1, Warning: 1},
|
||||
// Sad empty state
|
||||
Proxy: pbservice.ConnectProxyConfig{
|
||||
MeshGateway: pbservice.MeshGatewayConfig{},
|
||||
Expose: pbservice.ExposeConfig{},
|
||||
Proxy: &pbservice.ConnectProxyConfig{
|
||||
MeshGateway: &pbservice.MeshGatewayConfig{},
|
||||
Expose: &pbservice.ExposeConfig{},
|
||||
TransparentProxy: &pbservice.TransparentProxyConfig{},
|
||||
},
|
||||
EnterpriseMeta: pbcommongogo.DefaultEnterpriseMeta,
|
||||
Connect: &pbservice.ServiceConnect{},
|
||||
EnterpriseMeta: pbcommon.DefaultEnterpriseMeta,
|
||||
},
|
||||
Checks: []*pbservice.HealthCheck{
|
||||
{
|
||||
|
@ -604,7 +624,13 @@ func TestServer_Subscribe_IntegrationWithBackend_ForwardToDC(t *testing.T) {
|
|||
ServiceID: "redis1",
|
||||
ServiceName: "redis",
|
||||
RaftIndex: raftIndex(ids, "update", "update"),
|
||||
EnterpriseMeta: pbcommongogo.DefaultEnterpriseMeta,
|
||||
EnterpriseMeta: pbcommon.DefaultEnterpriseMeta,
|
||||
Definition: &pbservice.HealthCheckDefinition{
|
||||
Interval: &duration.Duration{},
|
||||
Timeout: &duration.Duration{},
|
||||
DeregisterCriticalServiceAfter: &duration.Duration{},
|
||||
TTL: &duration.Duration{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -986,8 +1012,18 @@ func TestNewEventFromSteamEvent(t *testing.T) {
|
|||
ServiceHealth: &pbsubscribe.ServiceHealthUpdate{
|
||||
Op: pbsubscribe.CatalogOp_Register,
|
||||
CheckServiceNode: &pbservice.CheckServiceNode{
|
||||
Node: &pbservice.Node{Node: "node1"},
|
||||
Service: &pbservice.NodeService{Service: "web1"},
|
||||
Node: &pbservice.Node{Node: "node1", RaftIndex: &pbcommon.RaftIndex{}},
|
||||
Service: &pbservice.NodeService{
|
||||
Service: "web1",
|
||||
Proxy: &pbservice.ConnectProxyConfig{
|
||||
MeshGateway: &pbservice.MeshGatewayConfig{},
|
||||
Expose: &pbservice.ExposeConfig{},
|
||||
TransparentProxy: &pbservice.TransparentProxyConfig{},
|
||||
},
|
||||
Connect: &pbservice.ServiceConnect{},
|
||||
EnterpriseMeta: &pbcommon.EnterpriseMeta{},
|
||||
RaftIndex: &pbcommon.RaftIndex{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -998,8 +1034,18 @@ func TestNewEventFromSteamEvent(t *testing.T) {
|
|||
ServiceHealth: &pbsubscribe.ServiceHealthUpdate{
|
||||
Op: pbsubscribe.CatalogOp_Deregister,
|
||||
CheckServiceNode: &pbservice.CheckServiceNode{
|
||||
Node: &pbservice.Node{Node: "node2"},
|
||||
Service: &pbservice.NodeService{Service: "web1"},
|
||||
Node: &pbservice.Node{Node: "node2", RaftIndex: &pbcommon.RaftIndex{}},
|
||||
Service: &pbservice.NodeService{
|
||||
Service: "web1",
|
||||
Proxy: &pbservice.ConnectProxyConfig{
|
||||
MeshGateway: &pbservice.MeshGatewayConfig{},
|
||||
Expose: &pbservice.ExposeConfig{},
|
||||
TransparentProxy: &pbservice.TransparentProxyConfig{},
|
||||
},
|
||||
Connect: &pbservice.ServiceConnect{},
|
||||
EnterpriseMeta: &pbcommon.EnterpriseMeta{},
|
||||
RaftIndex: &pbcommon.RaftIndex{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1027,8 +1073,18 @@ func TestNewEventFromSteamEvent(t *testing.T) {
|
|||
ServiceHealth: &pbsubscribe.ServiceHealthUpdate{
|
||||
Op: pbsubscribe.CatalogOp_Register,
|
||||
CheckServiceNode: &pbservice.CheckServiceNode{
|
||||
Node: &pbservice.Node{Node: "node1"},
|
||||
Service: &pbservice.NodeService{Service: "web1"},
|
||||
Node: &pbservice.Node{Node: "node1", RaftIndex: &pbcommon.RaftIndex{}},
|
||||
Service: &pbservice.NodeService{
|
||||
Service: "web1",
|
||||
Proxy: &pbservice.ConnectProxyConfig{
|
||||
MeshGateway: &pbservice.MeshGatewayConfig{},
|
||||
Expose: &pbservice.ExposeConfig{},
|
||||
TransparentProxy: &pbservice.TransparentProxyConfig{},
|
||||
},
|
||||
Connect: &pbservice.ServiceConnect{},
|
||||
EnterpriseMeta: &pbcommon.EnterpriseMeta{},
|
||||
RaftIndex: &pbcommon.RaftIndex{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/hashicorp/consul/proto/pbcommon"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -568,11 +569,11 @@ func newEventServiceHealthRegister(index uint64, nodeNum int, svc string) *pbsub
|
|||
Op: pbsubscribe.CatalogOp_Register,
|
||||
CheckServiceNode: &pbservice.CheckServiceNode{
|
||||
Node: &pbservice.Node{
|
||||
ID: nodeID,
|
||||
ID: string(nodeID),
|
||||
Node: node,
|
||||
Address: addr,
|
||||
Datacenter: "dc1",
|
||||
RaftIndex: pbcommongogo.RaftIndex{
|
||||
RaftIndex: &pbcommon.RaftIndex{
|
||||
CreateIndex: index,
|
||||
ModifyIndex: index,
|
||||
},
|
||||
|
@ -581,7 +582,7 @@ func newEventServiceHealthRegister(index uint64, nodeNum int, svc string) *pbsub
|
|||
ID: svc,
|
||||
Service: svc,
|
||||
Port: 8080,
|
||||
RaftIndex: pbcommongogo.RaftIndex{
|
||||
RaftIndex: &pbcommon.RaftIndex{
|
||||
CreateIndex: index,
|
||||
ModifyIndex: index,
|
||||
},
|
||||
|
@ -612,7 +613,7 @@ func newEventServiceHealthDeregister(index uint64, nodeNum int, svc string) *pbs
|
|||
Passing: 1,
|
||||
Warning: 1,
|
||||
},
|
||||
RaftIndex: pbcommongogo.RaftIndex{
|
||||
RaftIndex: &pbcommon.RaftIndex{
|
||||
// The original insertion index since a delete doesn't update
|
||||
// this. This magic value came from state store tests where we
|
||||
// setup at index 10 and then mutate at index 100. It can be
|
||||
|
|
|
@ -3,11 +3,11 @@ package submatview
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/hashicorp/consul/proto/pbcommon"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/hashicorp/consul/proto/pbcommongogo"
|
||||
"github.com/hashicorp/consul/proto/pbservice"
|
||||
"github.com/hashicorp/consul/proto/pbsubscribe"
|
||||
"github.com/hashicorp/consul/types"
|
||||
|
@ -116,11 +116,11 @@ func newEventServiceHealthRegister(index uint64, nodeNum int, svc string) *pbsub
|
|||
Op: pbsubscribe.CatalogOp_Register,
|
||||
CheckServiceNode: &pbservice.CheckServiceNode{
|
||||
Node: &pbservice.Node{
|
||||
ID: nodeID,
|
||||
ID: string(nodeID),
|
||||
Node: node,
|
||||
Address: addr,
|
||||
Datacenter: "dc1",
|
||||
RaftIndex: pbcommongogo.RaftIndex{
|
||||
RaftIndex: &pbcommon.RaftIndex{
|
||||
CreateIndex: index,
|
||||
ModifyIndex: index,
|
||||
},
|
||||
|
@ -129,7 +129,7 @@ func newEventServiceHealthRegister(index uint64, nodeNum int, svc string) *pbsub
|
|||
ID: svc,
|
||||
Service: svc,
|
||||
Port: 8080,
|
||||
RaftIndex: pbcommongogo.RaftIndex{
|
||||
RaftIndex: &pbcommon.RaftIndex{
|
||||
CreateIndex: index,
|
||||
ModifyIndex: index,
|
||||
},
|
||||
|
@ -160,7 +160,7 @@ func newEventServiceHealthDeregister(index uint64, nodeNum int, svc string) *pbs
|
|||
Passing: 1,
|
||||
Warning: 1,
|
||||
},
|
||||
RaftIndex: pbcommongogo.RaftIndex{
|
||||
RaftIndex: &pbcommon.RaftIndex{
|
||||
// The original insertion index since a delete doesn't update
|
||||
// this. This magic value came from state store tests where we
|
||||
// setup at index 10 and then mutate at index 100. It can be
|
||||
|
|
|
@ -14,6 +14,12 @@ elif [[ "$FILENAME" =~ .*pbconfig/.* ]]; then
|
|||
elif [[ "$FILENAME" =~ .*pbautoconf/.* ]]; then
|
||||
echo "$FILENAME no gogo"
|
||||
./build-support/scripts/proto-gen-no-gogo.sh $1 $2 $3
|
||||
elif [[ "$FILENAME" =~ .*pbservice/.* ]]; then
|
||||
echo "$FILENAME no gogo"
|
||||
./build-support/scripts/proto-gen-no-gogo.sh $1 $2 $3
|
||||
elif [[ "$FILENAME" =~ .*pbsubscribe/.* ]]; then
|
||||
echo "$FILENAME no gogo"
|
||||
./build-support/scripts/proto-gen-no-gogo.sh $1 $2 $3
|
||||
else
|
||||
echo "$FILENAME gogo"
|
||||
./build-support/scripts/proto-gen.sh $1 $2 $3
|
||||
|
|
2
go.mod
2
go.mod
|
@ -94,7 +94,7 @@ require (
|
|||
google.golang.org/api v0.9.0 // indirect
|
||||
google.golang.org/appengine v1.6.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55
|
||||
google.golang.org/grpc v1.25.1
|
||||
google.golang.org/grpc v1.27.1
|
||||
gopkg.in/square/go-jose.v2 v2.5.1
|
||||
gotest.tools/v3 v3.0.3
|
||||
k8s.io/api v0.18.2
|
||||
|
|
4
go.sum
4
go.sum
|
@ -130,6 +130,7 @@ github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0/go.mod
|
|||
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.5 h1:lRJIqDD8yjV1YyPRqecMdytjDLs2fTXq363aCib5xPU=
|
||||
github.com/envoyproxy/go-control-plane v0.9.5/go.mod h1:OXl5to++W0ctG+EHWTFUjiypVxC/Y4VLc/KFU+al13s=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=
|
||||
|
@ -714,8 +715,9 @@ google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiq
|
|||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1 h1:wdKvqQk7IttEw92GoRyKG2IDrUIpgpj6H6m81yfeMW0=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk=
|
||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/hashicorp/consul/agent/structs"
|
||||
)
|
||||
|
||||
var DefaultEnterpriseMeta = EnterpriseMeta{}
|
||||
var DefaultEnterpriseMeta = &EnterpriseMeta{}
|
||||
|
||||
func NewEnterpriseMetaFromStructs(_ structs.EnterpriseMeta) *EnterpriseMeta {
|
||||
return &EnterpriseMeta{}
|
||||
|
|
|
@ -2,24 +2,28 @@ package pbservice
|
|||
|
||||
import (
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/consul/proto/pbcommongogo"
|
||||
"github.com/hashicorp/consul/proto/pbcommon"
|
||||
"github.com/hashicorp/consul/types"
|
||||
)
|
||||
|
||||
func RaftIndexToStructs(s pbcommongogo.RaftIndex) structs.RaftIndex {
|
||||
type CheckIDType = types.CheckID
|
||||
type NodeIDType = types.NodeID
|
||||
|
||||
func RaftIndexToStructs(s *pbcommon.RaftIndex) structs.RaftIndex {
|
||||
return structs.RaftIndex{
|
||||
CreateIndex: s.CreateIndex,
|
||||
ModifyIndex: s.ModifyIndex,
|
||||
}
|
||||
}
|
||||
|
||||
func NewRaftIndexFromStructs(s structs.RaftIndex) pbcommongogo.RaftIndex {
|
||||
return pbcommongogo.RaftIndex{
|
||||
func NewRaftIndexFromStructs(s structs.RaftIndex) *pbcommon.RaftIndex {
|
||||
return &pbcommon.RaftIndex{
|
||||
CreateIndex: s.CreateIndex,
|
||||
ModifyIndex: s.ModifyIndex,
|
||||
}
|
||||
}
|
||||
|
||||
func MapHeadersToStructs(s map[string]HeaderValue) map[string][]string {
|
||||
func MapHeadersToStructs(s map[string]*HeaderValue) map[string][]string {
|
||||
t := make(map[string][]string, len(s))
|
||||
for k, v := range s {
|
||||
t[k] = v.Value
|
||||
|
@ -27,10 +31,10 @@ func MapHeadersToStructs(s map[string]HeaderValue) map[string][]string {
|
|||
return t
|
||||
}
|
||||
|
||||
func NewMapHeadersFromStructs(t map[string][]string) map[string]HeaderValue {
|
||||
s := make(map[string]HeaderValue, len(t))
|
||||
func NewMapHeadersFromStructs(t map[string][]string) map[string]*HeaderValue {
|
||||
s := make(map[string]*HeaderValue, len(t))
|
||||
for k, v := range t {
|
||||
s[k] = HeaderValue{Value: v}
|
||||
s[k] = &HeaderValue{Value: v}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
@ -42,23 +46,23 @@ func CheckServiceNodeToStructs(s *CheckServiceNode) (*structs.CheckServiceNode,
|
|||
}
|
||||
var t structs.CheckServiceNode
|
||||
if s.Node != nil {
|
||||
n := NodeToStructs(*s.Node)
|
||||
t.Node = &n
|
||||
n := new(structs.Node)
|
||||
NodeToStructs(s.Node, n)
|
||||
t.Node = n
|
||||
}
|
||||
if s.Service != nil {
|
||||
r := NodeServiceToStructs(*s.Service)
|
||||
t.Service = &r
|
||||
r := new(structs.NodeService)
|
||||
NodeServiceToStructs(s.Service, r)
|
||||
t.Service = r
|
||||
}
|
||||
t.Checks = make(structs.HealthChecks, len(s.Checks))
|
||||
for i, c := range s.Checks {
|
||||
if c == nil {
|
||||
continue
|
||||
}
|
||||
h, err := HealthCheckToStructs(*c)
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.Checks[i] = &h
|
||||
h := new(structs.HealthCheck)
|
||||
HealthCheckToStructs(c, h)
|
||||
t.Checks[i] = h
|
||||
}
|
||||
return &t, nil
|
||||
}
|
||||
|
@ -70,20 +74,23 @@ func NewCheckServiceNodeFromStructs(t *structs.CheckServiceNode) *CheckServiceNo
|
|||
}
|
||||
var s CheckServiceNode
|
||||
if t.Node != nil {
|
||||
n := NewNodeFromStructs(*t.Node)
|
||||
s.Node = &n
|
||||
n := new(Node)
|
||||
NodeFromStructs(t.Node, n)
|
||||
s.Node = n
|
||||
}
|
||||
if t.Service != nil {
|
||||
r := NewNodeServiceFromStructs(*t.Service)
|
||||
s.Service = &r
|
||||
r := new(NodeService)
|
||||
NodeServiceFromStructs(t.Service, r)
|
||||
s.Service = r
|
||||
}
|
||||
s.Checks = make([]*HealthCheck, len(t.Checks))
|
||||
for i, c := range t.Checks {
|
||||
if c == nil {
|
||||
continue
|
||||
}
|
||||
h := NewHealthCheckFromStructs(*c)
|
||||
s.Checks[i] = &h
|
||||
h := new(HealthCheck)
|
||||
HealthCheckFromStructs(c, h)
|
||||
s.Checks[i] = h
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
@ -111,7 +118,7 @@ func NewWeightsPtrFromStructs(t *structs.Weights) *Weights {
|
|||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
func MapStringServiceAddressToStructs(s map[string]ServiceAddress) map[string]structs.ServiceAddress {
|
||||
func MapStringServiceAddressToStructs(s map[string]*ServiceAddress) map[string]structs.ServiceAddress {
|
||||
t := make(map[string]structs.ServiceAddress, len(s))
|
||||
for k, v := range s {
|
||||
t[k] = structs.ServiceAddress{Address: v.Address, Port: int(v.Port)}
|
||||
|
@ -120,64 +127,70 @@ func MapStringServiceAddressToStructs(s map[string]ServiceAddress) map[string]st
|
|||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
func NewMapStringServiceAddressFromStructs(t map[string]structs.ServiceAddress) map[string]ServiceAddress {
|
||||
s := make(map[string]ServiceAddress, len(t))
|
||||
func NewMapStringServiceAddressFromStructs(t map[string]structs.ServiceAddress) map[string]*ServiceAddress {
|
||||
s := make(map[string]*ServiceAddress, len(t))
|
||||
for k, v := range t {
|
||||
s[k] = ServiceAddress{Address: v.Address, Port: int32(v.Port)}
|
||||
s[k] = &ServiceAddress{Address: v.Address, Port: int32(v.Port)}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
func ExposePathSliceToStructs(s []ExposePath) []structs.ExposePath {
|
||||
func ExposePathSliceToStructs(s []*ExposePath) []structs.ExposePath {
|
||||
t := make([]structs.ExposePath, len(s))
|
||||
for i, v := range s {
|
||||
t[i] = ExposePathToStructs(v)
|
||||
e := new(structs.ExposePath)
|
||||
ExposePathToStructs(v, e)
|
||||
t[i] = *e
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
func NewExposePathSliceFromStructs(t []structs.ExposePath) []ExposePath {
|
||||
s := make([]ExposePath, len(t))
|
||||
func NewExposePathSliceFromStructs(t []structs.ExposePath) []*ExposePath {
|
||||
s := make([]*ExposePath, len(t))
|
||||
for i, v := range t {
|
||||
s[i] = NewExposePathFromStructs(v)
|
||||
ep := new(ExposePath)
|
||||
ExposePathFromStructs(&v, ep)
|
||||
s[i] = ep
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
func UpstreamsToStructs(s []Upstream) structs.Upstreams {
|
||||
func UpstreamsToStructs(s []*Upstream) structs.Upstreams {
|
||||
t := make(structs.Upstreams, len(s))
|
||||
for i, v := range s {
|
||||
t[i] = UpstreamToStructs(v)
|
||||
u := new(structs.Upstream)
|
||||
UpstreamToStructs(v, u)
|
||||
t[i] = *u
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
func NewUpstreamsFromStructs(t structs.Upstreams) []Upstream {
|
||||
s := make([]Upstream, len(t))
|
||||
func NewUpstreamsFromStructs(t structs.Upstreams) []*Upstream {
|
||||
s := make([]*Upstream, len(t))
|
||||
for i, v := range t {
|
||||
s[i] = NewUpstreamFromStructs(v)
|
||||
u := new(Upstream)
|
||||
UpstreamFromStructs(&v, u)
|
||||
s[i] = u
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
func CheckTypesToStructs(s []*CheckType) (structs.CheckTypes, error) {
|
||||
func CheckTypesToStructs(s []*CheckType) structs.CheckTypes {
|
||||
t := make(structs.CheckTypes, len(s))
|
||||
for i, v := range s {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
newV, err := CheckTypeToStructs(*v)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t[i] = &newV
|
||||
c := new(structs.CheckType)
|
||||
CheckTypeToStructs(v, c)
|
||||
t[i] = c
|
||||
}
|
||||
return t, nil
|
||||
return t
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
|
@ -187,8 +200,9 @@ func NewCheckTypesFromStructs(t structs.CheckTypes) []*CheckType {
|
|||
if v == nil {
|
||||
continue
|
||||
}
|
||||
newV := NewCheckTypeFromStructs(*v)
|
||||
s[i] = &newV
|
||||
newV := new(CheckType)
|
||||
CheckTypeFromStructs(v, newV)
|
||||
s[i] = newV
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
@ -198,8 +212,9 @@ func ConnectProxyConfigPtrToStructs(s *ConnectProxyConfig) *structs.ConnectProxy
|
|||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
t := ConnectProxyConfigToStructs(*s)
|
||||
return &t
|
||||
c := new(structs.ConnectProxyConfig)
|
||||
ConnectProxyConfigToStructs(s, c)
|
||||
return c
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
|
@ -207,8 +222,9 @@ func NewConnectProxyConfigPtrFromStructs(t *structs.ConnectProxyConfig) *Connect
|
|||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
s := NewConnectProxyConfigFromStructs(*t)
|
||||
return &s
|
||||
cp := new(ConnectProxyConfig)
|
||||
ConnectProxyConfigFromStructs(t, cp)
|
||||
return cp
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
|
@ -216,8 +232,9 @@ func ServiceConnectPtrToStructs(s *ServiceConnect) *structs.ServiceConnect {
|
|||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
t := ServiceConnectToStructs(*s)
|
||||
return &t
|
||||
sc := new(structs.ServiceConnect)
|
||||
ServiceConnectToStructs(s, sc)
|
||||
return sc
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
|
@ -225,8 +242,9 @@ func NewServiceConnectPtrFromStructs(t *structs.ServiceConnect) *ServiceConnect
|
|||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
s := NewServiceConnectFromStructs(*t)
|
||||
return &s
|
||||
sc := new(ServiceConnect)
|
||||
ServiceConnectFromStructs(t, sc)
|
||||
return sc
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
|
@ -234,11 +252,9 @@ func ServiceDefinitionPtrToStructs(s *ServiceDefinition) *structs.ServiceDefinit
|
|||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
t, err := ServiceDefinitionToStructs(*s)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return &t
|
||||
sd := new(structs.ServiceDefinition)
|
||||
ServiceDefinitionToStructs(s, sd)
|
||||
return sd
|
||||
}
|
||||
|
||||
// TODO: handle this with mog
|
||||
|
@ -246,6 +262,7 @@ func NewServiceDefinitionPtrFromStructs(t *structs.ServiceDefinition) *ServiceDe
|
|||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
s := NewServiceDefinitionFromStructs(*t)
|
||||
return &s
|
||||
sd := new(ServiceDefinition)
|
||||
ServiceDefinitionFromStructs(t, sd)
|
||||
return sd
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ package pbservice
|
|||
|
||||
import (
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/consul/proto/pbcommongogo"
|
||||
"github.com/hashicorp/consul/proto/pbcommon"
|
||||
)
|
||||
|
||||
func EnterpriseMetaToStructs(_ pbcommongogo.EnterpriseMeta) structs.EnterpriseMeta {
|
||||
func EnterpriseMetaToStructs(_ *pbcommon.EnterpriseMeta) structs.EnterpriseMeta {
|
||||
return structs.EnterpriseMeta{}
|
||||
}
|
||||
|
||||
func NewEnterpriseMetaFromStructs(_ structs.EnterpriseMeta) pbcommongogo.EnterpriseMeta {
|
||||
return pbcommongogo.EnterpriseMeta{}
|
||||
func NewEnterpriseMetaFromStructs(_ structs.EnterpriseMeta) *pbcommon.EnterpriseMeta {
|
||||
return &pbcommon.EnterpriseMeta{}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ import (
|
|||
fmt "fmt"
|
||||
"reflect"
|
||||
|
||||
types "github.com/gogo/protobuf/types"
|
||||
//TODO(gogo-remove): remove the types alias
|
||||
types "github.com/golang/protobuf/ptypes/struct"
|
||||
)
|
||||
|
||||
// ProtobufTypesStructToMapStringInterface converts a protobuf/types.Struct into a
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
package pbservice
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/consul/proto/pbutil"
|
||||
)
|
||||
import "github.com/hashicorp/consul/agent/structs"
|
||||
|
||||
func CheckTypeToStructs(s CheckType) (structs.CheckType, error) {
|
||||
var t structs.CheckType
|
||||
t.CheckID = s.CheckID
|
||||
func CheckTypeToStructs(s *CheckType, t *structs.CheckType) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.CheckID = CheckIDType(s.CheckID)
|
||||
t.Name = s.Name
|
||||
t.Status = s.Status
|
||||
t.Notes = s.Notes
|
||||
|
@ -21,12 +20,7 @@ func CheckTypeToStructs(s CheckType) (structs.CheckType, error) {
|
|||
t.Method = s.Method
|
||||
t.Body = s.Body
|
||||
t.TCP = s.TCP
|
||||
interval, err := pbutil.DurationFromProto(&s.Interval)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.Interval = interval
|
||||
|
||||
t.Interval = structs.DurationFromProto(s.Interval)
|
||||
t.AliasNode = s.AliasNode
|
||||
t.AliasService = s.AliasService
|
||||
t.DockerContainerID = s.DockerContainerID
|
||||
|
@ -35,32 +29,21 @@ func CheckTypeToStructs(s CheckType) (structs.CheckType, error) {
|
|||
t.GRPCUseTLS = s.GRPCUseTLS
|
||||
t.TLSServerName = s.TLSServerName
|
||||
t.TLSSkipVerify = s.TLSSkipVerify
|
||||
timeout, err := pbutil.DurationFromProto(&s.Timeout)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.Timeout = timeout
|
||||
ttl, err := pbutil.DurationFromProto(&s.TTL)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.TTL = ttl
|
||||
t.Timeout = structs.DurationFromProto(s.Timeout)
|
||||
t.TTL = structs.DurationFromProto(s.TTL)
|
||||
t.SuccessBeforePassing = int(s.SuccessBeforePassing)
|
||||
t.FailuresBeforeCritical = int(s.FailuresBeforeCritical)
|
||||
t.FailuresBeforeWarning = int(s.FailuresBeforeWarning)
|
||||
t.FailuresBeforeCritical = int(s.FailuresBeforeCritical)
|
||||
t.ProxyHTTP = s.ProxyHTTP
|
||||
t.ProxyGRPC = s.ProxyGRPC
|
||||
deregisterCriticalServiceAfter, err := pbutil.DurationFromProto(&s.DeregisterCriticalServiceAfter)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.DeregisterCriticalServiceAfter = deregisterCriticalServiceAfter
|
||||
t.DeregisterCriticalServiceAfter = structs.DurationFromProto(s.DeregisterCriticalServiceAfter)
|
||||
t.OutputMaxSize = int(s.OutputMaxSize)
|
||||
return t, nil
|
||||
}
|
||||
func NewCheckTypeFromStructs(t structs.CheckType) CheckType {
|
||||
var s CheckType
|
||||
s.CheckID = t.CheckID
|
||||
func CheckTypeFromStructs(t *structs.CheckType, s *CheckType) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.CheckID = string(t.CheckID)
|
||||
s.Name = t.Name
|
||||
s.Status = t.Status
|
||||
s.Notes = t.Notes
|
||||
|
@ -72,7 +55,7 @@ func NewCheckTypeFromStructs(t structs.CheckType) CheckType {
|
|||
s.Method = t.Method
|
||||
s.Body = t.Body
|
||||
s.TCP = t.TCP
|
||||
s.Interval = *pbutil.DurationToProto(t.Interval)
|
||||
s.Interval = structs.DurationToProto(t.Interval)
|
||||
s.AliasNode = t.AliasNode
|
||||
s.AliasService = t.AliasService
|
||||
s.DockerContainerID = t.DockerContainerID
|
||||
|
@ -81,21 +64,22 @@ func NewCheckTypeFromStructs(t structs.CheckType) CheckType {
|
|||
s.GRPCUseTLS = t.GRPCUseTLS
|
||||
s.TLSServerName = t.TLSServerName
|
||||
s.TLSSkipVerify = t.TLSSkipVerify
|
||||
s.Timeout = *pbutil.DurationToProto(t.Timeout)
|
||||
s.TTL = *pbutil.DurationToProto(t.TTL)
|
||||
s.Timeout = structs.DurationToProto(t.Timeout)
|
||||
s.TTL = structs.DurationToProto(t.TTL)
|
||||
s.SuccessBeforePassing = int32(t.SuccessBeforePassing)
|
||||
s.FailuresBeforeCritical = int32(t.FailuresBeforeCritical)
|
||||
s.FailuresBeforeWarning = int32(t.FailuresBeforeWarning)
|
||||
s.FailuresBeforeCritical = int32(t.FailuresBeforeCritical)
|
||||
s.ProxyHTTP = t.ProxyHTTP
|
||||
s.ProxyGRPC = t.ProxyGRPC
|
||||
s.DeregisterCriticalServiceAfter = *pbutil.DurationToProto(t.DeregisterCriticalServiceAfter)
|
||||
s.DeregisterCriticalServiceAfter = structs.DurationToProto(t.DeregisterCriticalServiceAfter)
|
||||
s.OutputMaxSize = int32(t.OutputMaxSize)
|
||||
return s
|
||||
}
|
||||
func HealthCheckToStructs(s HealthCheck) (structs.HealthCheck, error) {
|
||||
var t structs.HealthCheck
|
||||
func HealthCheckToStructs(s *HealthCheck, t *structs.HealthCheck) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.Node = s.Node
|
||||
t.CheckID = s.CheckID
|
||||
t.CheckID = CheckIDType(s.CheckID)
|
||||
t.Name = s.Name
|
||||
t.Status = s.Status
|
||||
t.Notes = s.Notes
|
||||
|
@ -104,22 +88,21 @@ func HealthCheckToStructs(s HealthCheck) (structs.HealthCheck, error) {
|
|||
t.ServiceName = s.ServiceName
|
||||
t.ServiceTags = s.ServiceTags
|
||||
t.Type = s.Type
|
||||
t.ExposedPort = int(s.ExposedPort)
|
||||
definition, err := HealthCheckDefinitionToStructs(s.Definition)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.Definition = definition
|
||||
t.EnterpriseMeta = EnterpriseMetaToStructs(s.EnterpriseMeta)
|
||||
t.RaftIndex = RaftIndexToStructs(s.RaftIndex)
|
||||
t.Interval = s.Interval
|
||||
t.Timeout = s.Timeout
|
||||
return t, nil
|
||||
t.ExposedPort = int(s.ExposedPort)
|
||||
if s.Definition != nil {
|
||||
HealthCheckDefinitionToStructs(s.Definition, &t.Definition)
|
||||
}
|
||||
t.EnterpriseMeta = EnterpriseMetaToStructs(s.EnterpriseMeta)
|
||||
t.RaftIndex = RaftIndexToStructs(s.RaftIndex)
|
||||
}
|
||||
func NewHealthCheckFromStructs(t structs.HealthCheck) HealthCheck {
|
||||
var s HealthCheck
|
||||
func HealthCheckFromStructs(t *structs.HealthCheck, s *HealthCheck) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.Node = t.Node
|
||||
s.CheckID = t.CheckID
|
||||
s.CheckID = string(t.CheckID)
|
||||
s.Name = t.Name
|
||||
s.Status = t.Status
|
||||
s.Notes = t.Notes
|
||||
|
@ -128,16 +111,21 @@ func NewHealthCheckFromStructs(t structs.HealthCheck) HealthCheck {
|
|||
s.ServiceName = t.ServiceName
|
||||
s.ServiceTags = t.ServiceTags
|
||||
s.Type = t.Type
|
||||
s.ExposedPort = int32(t.ExposedPort)
|
||||
s.Definition = NewHealthCheckDefinitionFromStructs(t.Definition)
|
||||
s.EnterpriseMeta = NewEnterpriseMetaFromStructs(t.EnterpriseMeta)
|
||||
s.RaftIndex = NewRaftIndexFromStructs(t.RaftIndex)
|
||||
s.Interval = t.Interval
|
||||
s.Timeout = t.Timeout
|
||||
return s
|
||||
s.ExposedPort = int32(t.ExposedPort)
|
||||
{
|
||||
var x HealthCheckDefinition
|
||||
HealthCheckDefinitionFromStructs(&t.Definition, &x)
|
||||
s.Definition = &x
|
||||
}
|
||||
s.EnterpriseMeta = NewEnterpriseMetaFromStructs(t.EnterpriseMeta)
|
||||
s.RaftIndex = NewRaftIndexFromStructs(t.RaftIndex)
|
||||
}
|
||||
func HealthCheckDefinitionToStructs(s HealthCheckDefinition) (structs.HealthCheckDefinition, error) {
|
||||
var t structs.HealthCheckDefinition
|
||||
func HealthCheckDefinitionToStructs(s *HealthCheckDefinition, t *structs.HealthCheckDefinition) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.HTTP = s.HTTP
|
||||
t.TLSServerName = s.TLSServerName
|
||||
t.TLSSkipVerify = s.TLSSkipVerify
|
||||
|
@ -147,22 +135,10 @@ func HealthCheckDefinitionToStructs(s HealthCheckDefinition) (structs.HealthChec
|
|||
t.TCP = s.TCP
|
||||
t.H2PING = s.H2PING
|
||||
t.H2PingUseTLS = s.H2PingUseTLS
|
||||
interval, err := pbutil.DurationFromProto(&s.Interval)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.Interval = interval
|
||||
t.Interval = structs.DurationFromProto(s.Interval)
|
||||
t.OutputMaxSize = uint(s.OutputMaxSize)
|
||||
timeout, err := pbutil.DurationFromProto(&s.Timeout)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.Timeout = timeout
|
||||
deregisterCriticalServiceAfter, err := pbutil.DurationFromProto(&s.DeregisterCriticalServiceAfter)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.DeregisterCriticalServiceAfter = deregisterCriticalServiceAfter
|
||||
t.Timeout = structs.DurationFromProto(s.Timeout)
|
||||
t.DeregisterCriticalServiceAfter = structs.DurationFromProto(s.DeregisterCriticalServiceAfter)
|
||||
t.ScriptArgs = s.ScriptArgs
|
||||
t.DockerContainerID = s.DockerContainerID
|
||||
t.Shell = s.Shell
|
||||
|
@ -170,15 +146,12 @@ func HealthCheckDefinitionToStructs(s HealthCheckDefinition) (structs.HealthChec
|
|||
t.GRPCUseTLS = s.GRPCUseTLS
|
||||
t.AliasNode = s.AliasNode
|
||||
t.AliasService = s.AliasService
|
||||
ttl, err := pbutil.DurationFromProto(&s.TTL)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.TTL = ttl
|
||||
return t, nil
|
||||
t.TTL = structs.DurationFromProto(s.TTL)
|
||||
}
|
||||
func NewHealthCheckDefinitionFromStructs(t structs.HealthCheckDefinition) HealthCheckDefinition {
|
||||
var s HealthCheckDefinition
|
||||
func HealthCheckDefinitionFromStructs(t *structs.HealthCheckDefinition, s *HealthCheckDefinition) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.HTTP = t.HTTP
|
||||
s.TLSServerName = t.TLSServerName
|
||||
s.TLSSkipVerify = t.TLSSkipVerify
|
||||
|
@ -188,10 +161,10 @@ func NewHealthCheckDefinitionFromStructs(t structs.HealthCheckDefinition) Health
|
|||
s.TCP = t.TCP
|
||||
s.H2PING = t.H2PING
|
||||
s.H2PingUseTLS = t.H2PingUseTLS
|
||||
s.Interval = *pbutil.DurationToProto(t.Interval)
|
||||
s.Interval = structs.DurationToProto(t.Interval)
|
||||
s.OutputMaxSize = uint32(t.OutputMaxSize)
|
||||
s.Timeout = *pbutil.DurationToProto(t.Timeout)
|
||||
s.DeregisterCriticalServiceAfter = *pbutil.DurationToProto(t.DeregisterCriticalServiceAfter)
|
||||
s.Timeout = structs.DurationToProto(t.Timeout)
|
||||
s.DeregisterCriticalServiceAfter = structs.DurationToProto(t.DeregisterCriticalServiceAfter)
|
||||
s.ScriptArgs = t.ScriptArgs
|
||||
s.DockerContainerID = t.DockerContainerID
|
||||
s.Shell = t.Shell
|
||||
|
@ -199,6 +172,5 @@ func NewHealthCheckDefinitionFromStructs(t structs.HealthCheckDefinition) Health
|
|||
s.GRPCUseTLS = t.GRPCUseTLS
|
||||
s.AliasNode = t.AliasNode
|
||||
s.AliasService = t.AliasService
|
||||
s.TTL = *pbutil.DurationToProto(t.TTL)
|
||||
return s
|
||||
s.TTL = structs.DurationToProto(t.TTL)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,15 +5,7 @@ package pbservice;
|
|||
option go_package = "github.com/hashicorp/consul/proto/pbservice";
|
||||
|
||||
import "google/protobuf/duration.proto";
|
||||
import "proto/pbcommongogo/common.proto";
|
||||
|
||||
// This fake import path is replaced by the build script with a versioned path
|
||||
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;
|
||||
import "proto/pbcommon/common.proto";
|
||||
|
||||
// HealthCheck represents a single check on a given node
|
||||
//
|
||||
|
@ -24,7 +16,8 @@ option (gogoproto.goproto_sizecache_all) = false;
|
|||
// name=Structs
|
||||
message HealthCheck {
|
||||
string Node = 1;
|
||||
string CheckID = 2 [(gogoproto.casttype) = "github.com/hashicorp/consul/types.CheckID"];
|
||||
// mog: func-to=CheckIDType func-from=string
|
||||
string CheckID = 2;
|
||||
string Name = 3;
|
||||
string Status = 4; // The current check status
|
||||
string Notes = 5; // Additional notes with the status
|
||||
|
@ -34,13 +27,13 @@ message HealthCheck {
|
|||
repeated string ServiceTags = 9; // optional service tags
|
||||
string Type = 12; // Check type: http/ttl/tcp/etc
|
||||
|
||||
HealthCheckDefinition Definition = 10 [(gogoproto.nullable) = false];
|
||||
HealthCheckDefinition Definition = 10;
|
||||
|
||||
// mog: func-to=RaftIndexToStructs func-from=NewRaftIndexFromStructs
|
||||
commongogo.RaftIndex RaftIndex = 11 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
|
||||
common.RaftIndex RaftIndex = 11;
|
||||
|
||||
// mog: func-to=EnterpriseMetaToStructs func-from=NewEnterpriseMetaFromStructs
|
||||
commongogo.EnterpriseMeta EnterpriseMeta = 13 [(gogoproto.nullable) = false];
|
||||
common.EnterpriseMeta EnterpriseMeta = 13;
|
||||
|
||||
// mog: func-to=int func-from=int32
|
||||
int32 ExposedPort = 14;
|
||||
|
@ -66,19 +59,19 @@ message HealthCheckDefinition {
|
|||
bool TLSSkipVerify = 2;
|
||||
|
||||
// mog: func-to=MapHeadersToStructs func-from=NewMapHeadersFromStructs
|
||||
map<string, HeaderValue> Header = 3 [(gogoproto.nullable) = false];
|
||||
map<string, HeaderValue> Header = 3;
|
||||
string Method = 4;
|
||||
string Body = 18;
|
||||
string TCP = 5;
|
||||
google.protobuf.Duration Interval = 6
|
||||
[(gogoproto.nullable) = false];
|
||||
// mog: func-to=structs.DurationFromProto func-from=structs.DurationToProto
|
||||
google.protobuf.Duration Interval = 6;
|
||||
|
||||
// mog: func-to=uint func-from=uint32
|
||||
uint32 OutputMaxSize = 9;
|
||||
google.protobuf.Duration Timeout = 7
|
||||
[(gogoproto.nullable) = false];
|
||||
google.protobuf.Duration DeregisterCriticalServiceAfter = 8
|
||||
[(gogoproto.nullable) = false];
|
||||
// mog: func-to=structs.DurationFromProto func-from=structs.DurationToProto
|
||||
google.protobuf.Duration Timeout = 7;
|
||||
// mog: func-to=structs.DurationFromProto func-from=structs.DurationToProto
|
||||
google.protobuf.Duration DeregisterCriticalServiceAfter = 8;
|
||||
repeated string ScriptArgs = 10;
|
||||
string DockerContainerID = 11;
|
||||
string Shell = 12;
|
||||
|
@ -88,8 +81,8 @@ message HealthCheckDefinition {
|
|||
bool GRPCUseTLS = 14;
|
||||
string AliasNode = 15;
|
||||
string AliasService = 16;
|
||||
google.protobuf.Duration TTL = 17
|
||||
[(gogoproto.nullable) = false];
|
||||
// mog: func-to=structs.DurationFromProto func-from=structs.DurationToProto
|
||||
google.protobuf.Duration TTL = 17;
|
||||
}
|
||||
|
||||
// CheckType is used to create either the CheckMonitor or the CheckTTL.
|
||||
|
@ -105,7 +98,8 @@ message HealthCheckDefinition {
|
|||
// output=healthcheck.gen.go
|
||||
// name=Structs
|
||||
message CheckType {
|
||||
string CheckID = 1 [(gogoproto.casttype) = "github.com/hashicorp/consul/types.CheckID"];
|
||||
// mog: func-to=CheckIDType func-from=string
|
||||
string CheckID = 1;
|
||||
string Name = 2;
|
||||
string Status = 3;
|
||||
string Notes = 4;
|
||||
|
@ -113,12 +107,12 @@ message CheckType {
|
|||
repeated string ScriptArgs = 5;
|
||||
string HTTP = 6;
|
||||
// mog: func-to=MapHeadersToStructs func-from=NewMapHeadersFromStructs
|
||||
map<string, HeaderValue> Header = 20 [(gogoproto.nullable) = false];
|
||||
map<string, HeaderValue> Header = 20;
|
||||
string Method = 7;
|
||||
string Body = 26;
|
||||
string TCP = 8;
|
||||
google.protobuf.Duration Interval = 9
|
||||
[(gogoproto.nullable) = false];
|
||||
// mog: func-to=structs.DurationFromProto func-from=structs.DurationToProto
|
||||
google.protobuf.Duration Interval = 9;
|
||||
|
||||
string AliasNode = 10;
|
||||
string AliasService = 11;
|
||||
|
@ -130,10 +124,10 @@ message CheckType {
|
|||
bool GRPCUseTLS = 15;
|
||||
string TLSServerName = 27;
|
||||
bool TLSSkipVerify = 16;
|
||||
google.protobuf.Duration Timeout = 17
|
||||
[(gogoproto.nullable) = false];
|
||||
google.protobuf.Duration TTL = 18
|
||||
[(gogoproto.nullable) = false];
|
||||
// mog: func-to=structs.DurationFromProto func-from=structs.DurationToProto
|
||||
google.protobuf.Duration Timeout = 17;
|
||||
// mog: func-to=structs.DurationFromProto func-from=structs.DurationToProto
|
||||
google.protobuf.Duration TTL = 18;
|
||||
|
||||
// mog: func-to=int func-from=int32
|
||||
int32 SuccessBeforePassing = 21;
|
||||
|
@ -149,8 +143,8 @@ message CheckType {
|
|||
// DeregisterCriticalServiceAfter, if >0, will cause the associated
|
||||
// service, if any, to be deregistered if this check is critical for
|
||||
// longer than this duration.
|
||||
google.protobuf.Duration DeregisterCriticalServiceAfter = 19
|
||||
[(gogoproto.nullable) = false];
|
||||
// mog: func-to=structs.DurationFromProto func-from=structs.DurationToProto
|
||||
google.protobuf.Duration DeregisterCriticalServiceAfter = 19;
|
||||
|
||||
// mog: func-to=int func-from=int32
|
||||
int32 OutputMaxSize = 25;
|
||||
|
|
|
@ -23,14 +23,22 @@ func (m *CheckServiceNode) UniqueID() string {
|
|||
case m.Node != nil:
|
||||
builder.WriteString(m.Node.Partition + "/")
|
||||
case m.Service != nil:
|
||||
builder.WriteString(m.Service.EnterpriseMeta.Partition + "/")
|
||||
partition := ""
|
||||
if m.Service.EnterpriseMeta != nil {
|
||||
partition = m.Service.EnterpriseMeta.Partition
|
||||
}
|
||||
builder.WriteString(partition + "/")
|
||||
}
|
||||
|
||||
if m.Node != nil {
|
||||
builder.WriteString(m.Node.Node + "/")
|
||||
}
|
||||
if m.Service != nil {
|
||||
builder.WriteString(m.Service.EnterpriseMeta.Namespace + "/")
|
||||
namespace := ""
|
||||
if m.Service.EnterpriseMeta != nil {
|
||||
namespace = m.Service.EnterpriseMeta.Namespace
|
||||
}
|
||||
builder.WriteString(namespace + "/")
|
||||
builder.WriteString(m.Service.ID)
|
||||
}
|
||||
return builder.String()
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/hashicorp/consul/proto/pbcommongogo"
|
||||
"github.com/hashicorp/consul/proto/pbcommon"
|
||||
)
|
||||
|
||||
func TestCheckServiceNode_UniqueID(t *testing.T) {
|
||||
|
@ -25,7 +25,7 @@ func TestCheckServiceNode_UniqueID(t *testing.T) {
|
|||
Node: &Node{Node: "the-node-name"},
|
||||
Service: &NodeService{
|
||||
ID: "the-service-id",
|
||||
EnterpriseMeta: pbcommongogo.EnterpriseMeta{Namespace: "the-namespace"},
|
||||
EnterpriseMeta: &pbcommon.EnterpriseMeta{Namespace: "the-namespace"},
|
||||
},
|
||||
},
|
||||
expected: "/the-node-name/the-namespace/the-service-id",
|
||||
|
@ -35,7 +35,7 @@ func TestCheckServiceNode_UniqueID(t *testing.T) {
|
|||
csn: CheckServiceNode{
|
||||
Service: &NodeService{
|
||||
ID: "the-service-id",
|
||||
EnterpriseMeta: pbcommongogo.EnterpriseMeta{Namespace: "the-namespace"},
|
||||
EnterpriseMeta: &pbcommon.EnterpriseMeta{Namespace: "the-namespace"},
|
||||
},
|
||||
},
|
||||
expected: "/the-namespace/the-service-id",
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
|
||||
package pbservice
|
||||
|
||||
import structs "github.com/hashicorp/consul/agent/structs"
|
||||
import "github.com/hashicorp/consul/agent/structs"
|
||||
|
||||
func NodeToStructs(s Node) structs.Node {
|
||||
var t structs.Node
|
||||
t.ID = s.ID
|
||||
func NodeToStructs(s *Node, t *structs.Node) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.ID = NodeIDType(s.ID)
|
||||
t.Node = s.Node
|
||||
t.Address = s.Address
|
||||
t.Datacenter = s.Datacenter
|
||||
|
@ -14,11 +16,12 @@ func NodeToStructs(s Node) structs.Node {
|
|||
t.TaggedAddresses = s.TaggedAddresses
|
||||
t.Meta = s.Meta
|
||||
t.RaftIndex = RaftIndexToStructs(s.RaftIndex)
|
||||
return t
|
||||
}
|
||||
func NewNodeFromStructs(t structs.Node) Node {
|
||||
var s Node
|
||||
s.ID = t.ID
|
||||
func NodeFromStructs(t *structs.Node, s *Node) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.ID = string(t.ID)
|
||||
s.Node = t.Node
|
||||
s.Address = t.Address
|
||||
s.Datacenter = t.Datacenter
|
||||
|
@ -26,11 +29,12 @@ func NewNodeFromStructs(t structs.Node) Node {
|
|||
s.TaggedAddresses = t.TaggedAddresses
|
||||
s.Meta = t.Meta
|
||||
s.RaftIndex = NewRaftIndexFromStructs(t.RaftIndex)
|
||||
return s
|
||||
}
|
||||
func NodeServiceToStructs(s NodeService) structs.NodeService {
|
||||
var t structs.NodeService
|
||||
t.Kind = s.Kind
|
||||
func NodeServiceToStructs(s *NodeService, t *structs.NodeService) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.Kind = structs.ServiceKind(s.Kind)
|
||||
t.ID = s.ID
|
||||
t.Service = s.Service
|
||||
t.Tags = s.Tags
|
||||
|
@ -41,16 +45,21 @@ func NodeServiceToStructs(s NodeService) structs.NodeService {
|
|||
t.SocketPath = s.SocketPath
|
||||
t.Weights = WeightsPtrToStructs(s.Weights)
|
||||
t.EnableTagOverride = s.EnableTagOverride
|
||||
t.Proxy = ConnectProxyConfigToStructs(s.Proxy)
|
||||
t.Connect = ServiceConnectToStructs(s.Connect)
|
||||
if s.Proxy != nil {
|
||||
ConnectProxyConfigToStructs(s.Proxy, &t.Proxy)
|
||||
}
|
||||
if s.Connect != nil {
|
||||
ServiceConnectToStructs(s.Connect, &t.Connect)
|
||||
}
|
||||
t.LocallyRegisteredAsSidecar = s.LocallyRegisteredAsSidecar
|
||||
t.EnterpriseMeta = EnterpriseMetaToStructs(s.EnterpriseMeta)
|
||||
t.RaftIndex = RaftIndexToStructs(s.RaftIndex)
|
||||
return t
|
||||
}
|
||||
func NewNodeServiceFromStructs(t structs.NodeService) NodeService {
|
||||
var s NodeService
|
||||
s.Kind = t.Kind
|
||||
func NodeServiceFromStructs(t *structs.NodeService, s *NodeService) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.Kind = string(t.Kind)
|
||||
s.ID = t.ID
|
||||
s.Service = t.Service
|
||||
s.Tags = t.Tags
|
||||
|
@ -61,10 +70,17 @@ func NewNodeServiceFromStructs(t structs.NodeService) NodeService {
|
|||
s.SocketPath = t.SocketPath
|
||||
s.Weights = NewWeightsPtrFromStructs(t.Weights)
|
||||
s.EnableTagOverride = t.EnableTagOverride
|
||||
s.Proxy = NewConnectProxyConfigFromStructs(t.Proxy)
|
||||
s.Connect = NewServiceConnectFromStructs(t.Connect)
|
||||
{
|
||||
var x ConnectProxyConfig
|
||||
ConnectProxyConfigFromStructs(&t.Proxy, &x)
|
||||
s.Proxy = &x
|
||||
}
|
||||
{
|
||||
var x ServiceConnect
|
||||
ServiceConnectFromStructs(&t.Connect, &x)
|
||||
s.Connect = &x
|
||||
}
|
||||
s.LocallyRegisteredAsSidecar = t.LocallyRegisteredAsSidecar
|
||||
s.EnterpriseMeta = NewEnterpriseMetaFromStructs(t.EnterpriseMeta)
|
||||
s.RaftIndex = NewRaftIndexFromStructs(t.RaftIndex)
|
||||
return s
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,18 +4,10 @@ package pbservice;
|
|||
|
||||
option go_package = "github.com/hashicorp/consul/proto/pbservice";
|
||||
|
||||
import "proto/pbcommongogo/common.proto";
|
||||
import "proto/pbcommon/common.proto";
|
||||
import "proto/pbservice/healthcheck.proto";
|
||||
import "proto/pbservice/service.proto";
|
||||
|
||||
// This fake import path is replaced by the build script with a versioned path
|
||||
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;
|
||||
|
||||
// CheckServiceNode is used to provide the node, its service
|
||||
// definition, as well as a HealthCheck that is associated.
|
||||
message CheckServiceNode {
|
||||
|
@ -32,7 +24,8 @@ message CheckServiceNode {
|
|||
// output=node.gen.go
|
||||
// name=Structs
|
||||
message Node {
|
||||
string ID = 1 [(gogoproto.casttype) = "github.com/hashicorp/consul/types.NodeID"];
|
||||
// mog: func-to=NodeIDType func-from=string
|
||||
string ID = 1;
|
||||
|
||||
string Node = 2;
|
||||
string Partition = 8;
|
||||
|
@ -42,7 +35,7 @@ message Node {
|
|||
map<string, string> Meta = 6;
|
||||
|
||||
// mog: func-to=RaftIndexToStructs func-from=NewRaftIndexFromStructs
|
||||
commongogo.RaftIndex RaftIndex = 7 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
|
||||
common.RaftIndex RaftIndex = 7;
|
||||
}
|
||||
|
||||
// NodeService is a service provided by a node
|
||||
|
@ -56,14 +49,15 @@ message NodeService {
|
|||
// Kind is the kind of service this is. Different kinds of services may
|
||||
// have differing validation, DNS behavior, etc. An empty kind will default
|
||||
// to the Default kind. See ServiceKind for the full list of kinds.
|
||||
string Kind = 1 [(gogoproto.casttype) = "github.com/hashicorp/consul/agent/structs.ServiceKind"];
|
||||
// mog: func-to=structs.ServiceKind func-from=string
|
||||
string Kind = 1;
|
||||
|
||||
string ID = 2;
|
||||
string Service = 3;
|
||||
repeated string Tags = 4;
|
||||
string Address = 5;
|
||||
// mog: func-to=MapStringServiceAddressToStructs func-from=NewMapStringServiceAddressFromStructs
|
||||
map<string, ServiceAddress> TaggedAddresses = 15 [(gogoproto.nullable) = false];
|
||||
map<string, ServiceAddress> TaggedAddresses = 15;
|
||||
map<string, string> Meta = 6;
|
||||
// mog: func-to=int func-from=int32
|
||||
int32 Port = 7;
|
||||
|
@ -83,11 +77,11 @@ message NodeService {
|
|||
// in the other case. ProxyConfig may be a more natural name here, but it's
|
||||
// confusing for the UX because one of the fields in ConnectProxyConfig is
|
||||
// also called just "Config"
|
||||
ConnectProxyConfig Proxy = 11 [(gogoproto.nullable) = false];
|
||||
ConnectProxyConfig Proxy = 11;
|
||||
|
||||
// Connect are the Connect settings for a service. This is purposely NOT
|
||||
// a pointer so that we never have to nil-check this.
|
||||
ServiceConnect Connect = 12 [(gogoproto.nullable) = false];
|
||||
ServiceConnect Connect = 12;
|
||||
|
||||
// LocallyRegisteredAsSidecar is private as it is only used by a local agent
|
||||
// state to track if the service was registered from a nested sidecar_service
|
||||
|
@ -109,8 +103,8 @@ message NodeService {
|
|||
bool LocallyRegisteredAsSidecar = 13;
|
||||
|
||||
// mog: func-to=EnterpriseMetaToStructs func-from=NewEnterpriseMetaFromStructs
|
||||
commongogo.EnterpriseMeta EnterpriseMeta = 16 [(gogoproto.nullable) = false];
|
||||
common.EnterpriseMeta EnterpriseMeta = 16;
|
||||
|
||||
// mog: func-to=RaftIndexToStructs func-from=NewRaftIndexFromStructs
|
||||
commongogo.RaftIndex RaftIndex = 14 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
|
||||
common.RaftIndex RaftIndex = 14;
|
||||
}
|
||||
|
|
|
@ -2,93 +2,123 @@
|
|||
|
||||
package pbservice
|
||||
|
||||
import structs "github.com/hashicorp/consul/agent/structs"
|
||||
import "github.com/hashicorp/consul/agent/structs"
|
||||
|
||||
func ConnectProxyConfigToStructs(s ConnectProxyConfig) structs.ConnectProxyConfig {
|
||||
var t structs.ConnectProxyConfig
|
||||
func ConnectProxyConfigToStructs(s *ConnectProxyConfig, t *structs.ConnectProxyConfig) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.DestinationServiceName = s.DestinationServiceName
|
||||
t.DestinationServiceID = s.DestinationServiceID
|
||||
t.LocalServiceAddress = s.LocalServiceAddress
|
||||
t.LocalServicePort = int(s.LocalServicePort)
|
||||
t.LocalServiceSocketPath = s.LocalServiceSocketPath
|
||||
t.Mode = s.Mode
|
||||
t.Mode = structs.ProxyMode(s.Mode)
|
||||
t.Config = ProtobufTypesStructToMapStringInterface(s.Config)
|
||||
t.Upstreams = UpstreamsToStructs(s.Upstreams)
|
||||
t.MeshGateway = MeshGatewayConfigToStructs(s.MeshGateway)
|
||||
t.Expose = ExposeConfigToStructs(s.Expose)
|
||||
t.TransparentProxy = TransparentProxyConfigToStructs(s.TransparentProxy)
|
||||
return t
|
||||
if s.MeshGateway != nil {
|
||||
MeshGatewayConfigToStructs(s.MeshGateway, &t.MeshGateway)
|
||||
}
|
||||
if s.Expose != nil {
|
||||
ExposeConfigToStructs(s.Expose, &t.Expose)
|
||||
}
|
||||
if s.TransparentProxy != nil {
|
||||
TransparentProxyConfigToStructs(s.TransparentProxy, &t.TransparentProxy)
|
||||
}
|
||||
}
|
||||
func NewConnectProxyConfigFromStructs(t structs.ConnectProxyConfig) ConnectProxyConfig {
|
||||
var s ConnectProxyConfig
|
||||
func ConnectProxyConfigFromStructs(t *structs.ConnectProxyConfig, s *ConnectProxyConfig) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.DestinationServiceName = t.DestinationServiceName
|
||||
s.DestinationServiceID = t.DestinationServiceID
|
||||
s.LocalServiceAddress = t.LocalServiceAddress
|
||||
s.LocalServicePort = int32(t.LocalServicePort)
|
||||
s.LocalServiceSocketPath = t.LocalServiceSocketPath
|
||||
s.Mode = t.Mode
|
||||
s.Mode = string(t.Mode)
|
||||
s.Config = MapStringInterfaceToProtobufTypesStruct(t.Config)
|
||||
s.Upstreams = NewUpstreamsFromStructs(t.Upstreams)
|
||||
s.MeshGateway = NewMeshGatewayConfigFromStructs(t.MeshGateway)
|
||||
s.Expose = NewExposeConfigFromStructs(t.Expose)
|
||||
s.TransparentProxy = NewTransparentProxyConfigFromStructs(t.TransparentProxy)
|
||||
return s
|
||||
{
|
||||
var x MeshGatewayConfig
|
||||
MeshGatewayConfigFromStructs(&t.MeshGateway, &x)
|
||||
s.MeshGateway = &x
|
||||
}
|
||||
{
|
||||
var x ExposeConfig
|
||||
ExposeConfigFromStructs(&t.Expose, &x)
|
||||
s.Expose = &x
|
||||
}
|
||||
{
|
||||
var x TransparentProxyConfig
|
||||
TransparentProxyConfigFromStructs(&t.TransparentProxy, &x)
|
||||
s.TransparentProxy = &x
|
||||
}
|
||||
}
|
||||
func ExposeConfigToStructs(s ExposeConfig) structs.ExposeConfig {
|
||||
var t structs.ExposeConfig
|
||||
func ExposeConfigToStructs(s *ExposeConfig, t *structs.ExposeConfig) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.Checks = s.Checks
|
||||
t.Paths = ExposePathSliceToStructs(s.Paths)
|
||||
return t
|
||||
}
|
||||
func NewExposeConfigFromStructs(t structs.ExposeConfig) ExposeConfig {
|
||||
var s ExposeConfig
|
||||
func ExposeConfigFromStructs(t *structs.ExposeConfig, s *ExposeConfig) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.Checks = t.Checks
|
||||
s.Paths = NewExposePathSliceFromStructs(t.Paths)
|
||||
return s
|
||||
}
|
||||
func ExposePathToStructs(s ExposePath) structs.ExposePath {
|
||||
var t structs.ExposePath
|
||||
func ExposePathToStructs(s *ExposePath, t *structs.ExposePath) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.ListenerPort = int(s.ListenerPort)
|
||||
t.Path = s.Path
|
||||
t.LocalPathPort = int(s.LocalPathPort)
|
||||
t.Protocol = s.Protocol
|
||||
t.ParsedFromCheck = s.ParsedFromCheck
|
||||
return t
|
||||
}
|
||||
func NewExposePathFromStructs(t structs.ExposePath) ExposePath {
|
||||
var s ExposePath
|
||||
func ExposePathFromStructs(t *structs.ExposePath, s *ExposePath) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.ListenerPort = int32(t.ListenerPort)
|
||||
s.Path = t.Path
|
||||
s.LocalPathPort = int32(t.LocalPathPort)
|
||||
s.Protocol = t.Protocol
|
||||
s.ParsedFromCheck = t.ParsedFromCheck
|
||||
return s
|
||||
}
|
||||
func MeshGatewayConfigToStructs(s MeshGatewayConfig) structs.MeshGatewayConfig {
|
||||
var t structs.MeshGatewayConfig
|
||||
t.Mode = s.Mode
|
||||
return t
|
||||
func MeshGatewayConfigToStructs(s *MeshGatewayConfig, t *structs.MeshGatewayConfig) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.Mode = structs.MeshGatewayMode(s.Mode)
|
||||
}
|
||||
func NewMeshGatewayConfigFromStructs(t structs.MeshGatewayConfig) MeshGatewayConfig {
|
||||
var s MeshGatewayConfig
|
||||
s.Mode = t.Mode
|
||||
return s
|
||||
func MeshGatewayConfigFromStructs(t *structs.MeshGatewayConfig, s *MeshGatewayConfig) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.Mode = string(t.Mode)
|
||||
}
|
||||
func ServiceConnectToStructs(s ServiceConnect) structs.ServiceConnect {
|
||||
var t structs.ServiceConnect
|
||||
func ServiceConnectToStructs(s *ServiceConnect, t *structs.ServiceConnect) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.Native = s.Native
|
||||
t.SidecarService = ServiceDefinitionPtrToStructs(s.SidecarService)
|
||||
return t
|
||||
}
|
||||
func NewServiceConnectFromStructs(t structs.ServiceConnect) ServiceConnect {
|
||||
var s ServiceConnect
|
||||
func ServiceConnectFromStructs(t *structs.ServiceConnect, s *ServiceConnect) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.Native = t.Native
|
||||
s.SidecarService = NewServiceDefinitionPtrFromStructs(t.SidecarService)
|
||||
return s
|
||||
}
|
||||
func ServiceDefinitionToStructs(s ServiceDefinition) (structs.ServiceDefinition, error) {
|
||||
var t structs.ServiceDefinition
|
||||
t.Kind = s.Kind
|
||||
func ServiceDefinitionToStructs(s *ServiceDefinition, t *structs.ServiceDefinition) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.Kind = structs.ServiceKind(s.Kind)
|
||||
t.ID = s.ID
|
||||
t.Name = s.Name
|
||||
t.Tags = s.Tags
|
||||
|
@ -97,27 +127,22 @@ func ServiceDefinitionToStructs(s ServiceDefinition) (structs.ServiceDefinition,
|
|||
t.Meta = s.Meta
|
||||
t.Port = int(s.Port)
|
||||
t.SocketPath = s.SocketPath
|
||||
check, err := CheckTypeToStructs(s.Check)
|
||||
if err != nil {
|
||||
return t, err
|
||||
if s.Check != nil {
|
||||
CheckTypeToStructs(s.Check, &t.Check)
|
||||
}
|
||||
t.Check = check
|
||||
checks, err := CheckTypesToStructs(s.Checks)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.Checks = checks
|
||||
t.Checks = CheckTypesToStructs(s.Checks)
|
||||
t.Weights = WeightsPtrToStructs(s.Weights)
|
||||
t.Token = s.Token
|
||||
t.EnableTagOverride = s.EnableTagOverride
|
||||
t.Proxy = ConnectProxyConfigPtrToStructs(s.Proxy)
|
||||
t.EnterpriseMeta = EnterpriseMetaToStructs(s.EnterpriseMeta)
|
||||
t.Connect = ServiceConnectPtrToStructs(s.Connect)
|
||||
return t, nil
|
||||
}
|
||||
func NewServiceDefinitionFromStructs(t structs.ServiceDefinition) ServiceDefinition {
|
||||
var s ServiceDefinition
|
||||
s.Kind = t.Kind
|
||||
func ServiceDefinitionFromStructs(t *structs.ServiceDefinition, s *ServiceDefinition) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.Kind = string(t.Kind)
|
||||
s.ID = t.ID
|
||||
s.Name = t.Name
|
||||
s.Tags = t.Tags
|
||||
|
@ -126,7 +151,11 @@ func NewServiceDefinitionFromStructs(t structs.ServiceDefinition) ServiceDefinit
|
|||
s.Meta = t.Meta
|
||||
s.Port = int32(t.Port)
|
||||
s.SocketPath = t.SocketPath
|
||||
s.Check = NewCheckTypeFromStructs(t.Check)
|
||||
{
|
||||
var x CheckType
|
||||
CheckTypeFromStructs(&t.Check, &x)
|
||||
s.Check = &x
|
||||
}
|
||||
s.Checks = NewCheckTypesFromStructs(t.Checks)
|
||||
s.Weights = NewWeightsPtrFromStructs(t.Weights)
|
||||
s.Token = t.Token
|
||||
|
@ -134,22 +163,25 @@ func NewServiceDefinitionFromStructs(t structs.ServiceDefinition) ServiceDefinit
|
|||
s.Proxy = NewConnectProxyConfigPtrFromStructs(t.Proxy)
|
||||
s.EnterpriseMeta = NewEnterpriseMetaFromStructs(t.EnterpriseMeta)
|
||||
s.Connect = NewServiceConnectPtrFromStructs(t.Connect)
|
||||
return s
|
||||
}
|
||||
func TransparentProxyConfigToStructs(s TransparentProxyConfig) structs.TransparentProxyConfig {
|
||||
var t structs.TransparentProxyConfig
|
||||
func TransparentProxyConfigToStructs(s *TransparentProxyConfig, t *structs.TransparentProxyConfig) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.OutboundListenerPort = int(s.OutboundListenerPort)
|
||||
t.DialedDirectly = s.DialedDirectly
|
||||
return t
|
||||
}
|
||||
func NewTransparentProxyConfigFromStructs(t structs.TransparentProxyConfig) TransparentProxyConfig {
|
||||
var s TransparentProxyConfig
|
||||
func TransparentProxyConfigFromStructs(t *structs.TransparentProxyConfig, s *TransparentProxyConfig) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.OutboundListenerPort = int32(t.OutboundListenerPort)
|
||||
s.DialedDirectly = t.DialedDirectly
|
||||
return s
|
||||
}
|
||||
func UpstreamToStructs(s Upstream) structs.Upstream {
|
||||
var t structs.Upstream
|
||||
func UpstreamToStructs(s *Upstream, t *structs.Upstream) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
t.DestinationType = s.DestinationType
|
||||
t.DestinationNamespace = s.DestinationNamespace
|
||||
t.DestinationPartition = s.DestinationPartition
|
||||
|
@ -160,12 +192,15 @@ func UpstreamToStructs(s Upstream) structs.Upstream {
|
|||
t.LocalBindSocketPath = s.LocalBindSocketPath
|
||||
t.LocalBindSocketMode = s.LocalBindSocketMode
|
||||
t.Config = ProtobufTypesStructToMapStringInterface(s.Config)
|
||||
t.MeshGateway = MeshGatewayConfigToStructs(s.MeshGateway)
|
||||
if s.MeshGateway != nil {
|
||||
MeshGatewayConfigToStructs(s.MeshGateway, &t.MeshGateway)
|
||||
}
|
||||
t.CentrallyConfigured = s.CentrallyConfigured
|
||||
return t
|
||||
}
|
||||
func NewUpstreamFromStructs(t structs.Upstream) Upstream {
|
||||
var s Upstream
|
||||
func UpstreamFromStructs(t *structs.Upstream, s *Upstream) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.DestinationType = t.DestinationType
|
||||
s.DestinationNamespace = t.DestinationNamespace
|
||||
s.DestinationPartition = t.DestinationPartition
|
||||
|
@ -176,7 +211,10 @@ func NewUpstreamFromStructs(t structs.Upstream) Upstream {
|
|||
s.LocalBindSocketPath = t.LocalBindSocketPath
|
||||
s.LocalBindSocketMode = t.LocalBindSocketMode
|
||||
s.Config = MapStringInterfaceToProtobufTypesStruct(t.Config)
|
||||
s.MeshGateway = NewMeshGatewayConfigFromStructs(t.MeshGateway)
|
||||
{
|
||||
var x MeshGatewayConfig
|
||||
MeshGatewayConfigFromStructs(&t.MeshGateway, &x)
|
||||
s.MeshGateway = &x
|
||||
}
|
||||
s.CentrallyConfigured = t.CentrallyConfigured
|
||||
return s
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,17 +5,9 @@ package pbservice;
|
|||
option go_package = "github.com/hashicorp/consul/proto/pbservice";
|
||||
|
||||
import "google/protobuf/struct.proto";
|
||||
import "proto/pbcommongogo/common.proto";
|
||||
import "proto/pbcommon/common.proto";
|
||||
import "proto/pbservice/healthcheck.proto";
|
||||
|
||||
// This fake import path is replaced by the build script with a versioned path
|
||||
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;
|
||||
|
||||
|
||||
// ConnectProxyConfig describes the configuration needed for any proxy managed
|
||||
// or unmanaged. It describes a single logical service's listener and optionally
|
||||
|
@ -57,25 +49,26 @@ message ConnectProxyConfig {
|
|||
// Config is the arbitrary configuration data provided with the proxy
|
||||
// registration.
|
||||
// mog: func-to=ProtobufTypesStructToMapStringInterface func-from=MapStringInterfaceToProtobufTypesStruct
|
||||
google.protobuf.Struct Config = 5 [(gogoproto.nullable) = true];
|
||||
google.protobuf.Struct Config = 5;
|
||||
|
||||
// Upstreams describes any upstream dependencies the proxy instance should
|
||||
// setup.
|
||||
// mog: func-to=UpstreamsToStructs func-from=NewUpstreamsFromStructs
|
||||
repeated Upstream Upstreams = 6 [(gogoproto.nullable) = false];
|
||||
repeated Upstream Upstreams = 6;
|
||||
|
||||
// MeshGateway defines the mesh gateway configuration for upstreams
|
||||
MeshGatewayConfig MeshGateway = 7 [(gogoproto.nullable) = false];
|
||||
MeshGatewayConfig MeshGateway = 7;
|
||||
|
||||
// Expose defines whether checks or paths are exposed through the proxy
|
||||
ExposeConfig Expose = 8 [(gogoproto.nullable) = false];
|
||||
ExposeConfig Expose = 8;
|
||||
|
||||
// Mode represents how the proxy's inbound and upstream listeners are dialed.
|
||||
string Mode = 9 [(gogoproto.casttype) = "github.com/hashicorp/consul/agent/structs.ProxyMode"];
|
||||
// mog: func-to=structs.ProxyMode func-from=string
|
||||
string Mode = 9;
|
||||
|
||||
// TransparentProxy defines configuration for when the proxy is in
|
||||
// transparent mode.
|
||||
TransparentProxyConfig TransparentProxy = 10 [(gogoproto.nullable) = false];
|
||||
TransparentProxyConfig TransparentProxy = 10;
|
||||
|
||||
// LocalServiceSocketPath is the path to the unix domain socket for the local service instance
|
||||
string LocalServiceSocketPath = 11;
|
||||
|
@ -122,10 +115,10 @@ message Upstream {
|
|||
// It can be used to pass arbitrary configuration for this specific upstream
|
||||
// to the proxy.
|
||||
// mog: func-to=ProtobufTypesStructToMapStringInterface func-from=MapStringInterfaceToProtobufTypesStruct
|
||||
google.protobuf.Struct Config = 7 [(gogoproto.nullable) = true];
|
||||
google.protobuf.Struct Config = 7;
|
||||
|
||||
// MeshGateway is the configuration for mesh gateway usage of this upstream
|
||||
MeshGatewayConfig MeshGateway = 8 [(gogoproto.nullable) = false];
|
||||
MeshGatewayConfig MeshGateway = 8;
|
||||
|
||||
// CentrallyConfigured indicates whether the upstream was defined in a proxy
|
||||
// instance registration or whether it was generated from a config entry.
|
||||
|
@ -174,7 +167,7 @@ message ExposeConfig {
|
|||
|
||||
// Paths is the list of paths exposed through the proxy.
|
||||
// mog: func-to=ExposePathSliceToStructs func-from=NewExposePathSliceFromStructs
|
||||
repeated ExposePath Paths = 2 [(gogoproto.nullable) = false];
|
||||
repeated ExposePath Paths = 2;
|
||||
}
|
||||
|
||||
// mog annotation:
|
||||
|
@ -208,7 +201,8 @@ message ExposePath {
|
|||
// output=service.gen.go
|
||||
// name=Structs
|
||||
message MeshGatewayConfig {
|
||||
string Mode = 1 [(gogoproto.casttype) = "github.com/hashicorp/consul/agent/structs.MeshGatewayMode"];
|
||||
// mog: func-to=structs.MeshGatewayMode func-from=string
|
||||
string Mode = 1;
|
||||
}
|
||||
|
||||
// mog annotation:
|
||||
|
@ -235,19 +229,20 @@ message TransparentProxyConfig {
|
|||
// output=service.gen.go
|
||||
// name=Structs
|
||||
message ServiceDefinition {
|
||||
string Kind = 1 [(gogoproto.casttype) = "github.com/hashicorp/consul/agent/structs.ServiceKind"];
|
||||
// mog: func-to=structs.ServiceKind func-from=string
|
||||
string Kind = 1;
|
||||
string ID = 2;
|
||||
string Name = 3;
|
||||
repeated string Tags = 4;
|
||||
string Address = 5;
|
||||
// mog: func-to=MapStringServiceAddressToStructs func-from=NewMapStringServiceAddressFromStructs
|
||||
map<string, ServiceAddress> TaggedAddresses = 16 [(gogoproto.nullable) = false];
|
||||
map<string, ServiceAddress> TaggedAddresses = 16;
|
||||
map<string, string> Meta = 6;
|
||||
// mog: func-to=int func-from=int32
|
||||
int32 Port = 7;
|
||||
// Path for socket
|
||||
string SocketPath = 18;
|
||||
CheckType Check = 8 [(gogoproto.nullable) = false];
|
||||
CheckType Check = 8;
|
||||
// mog: func-to=CheckTypesToStructs func-from=NewCheckTypesFromStructs
|
||||
repeated CheckType Checks = 9;
|
||||
// mog: func-to=WeightsPtrToStructs func-from=NewWeightsPtrFromStructs
|
||||
|
@ -269,7 +264,7 @@ message ServiceDefinition {
|
|||
ConnectProxyConfig Proxy = 14;
|
||||
|
||||
// mog: func-to=EnterpriseMetaToStructs func-from=NewEnterpriseMetaFromStructs
|
||||
commongogo.EnterpriseMeta EnterpriseMeta = 17 [(gogoproto.nullable) = false];
|
||||
common.EnterpriseMeta EnterpriseMeta = 17;
|
||||
|
||||
// mog: func-to=ServiceConnectPtrToStructs func-from=NewServiceConnectPtrFromStructs
|
||||
ServiceConnect Connect = 15;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue