|
|
|
@ -22,16 +22,16 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// clustersFromSnapshot returns the xDS API representation of the "clusters" in the snapshot.
|
|
|
|
|
func (s *Server) clustersFromSnapshot(cfgSnap *proxycfg.ConfigSnapshot, token string) ([]proto.Message, error) {
|
|
|
|
|
func (s *Server) clustersFromSnapshot(cfgSnap *proxycfg.ConfigSnapshot, _ string) ([]proto.Message, error) {
|
|
|
|
|
if cfgSnap == nil {
|
|
|
|
|
return nil, errors.New("nil config given")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch cfgSnap.Kind {
|
|
|
|
|
case structs.ServiceKindConnectProxy:
|
|
|
|
|
return s.clustersFromSnapshotConnectProxy(cfgSnap, token)
|
|
|
|
|
return s.clustersFromSnapshotConnectProxy(cfgSnap)
|
|
|
|
|
case structs.ServiceKindMeshGateway:
|
|
|
|
|
return s.clustersFromSnapshotMeshGateway(cfgSnap, token)
|
|
|
|
|
return s.clustersFromSnapshotMeshGateway(cfgSnap)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("Invalid service kind: %v", cfgSnap.Kind)
|
|
|
|
|
}
|
|
|
|
@ -39,7 +39,7 @@ func (s *Server) clustersFromSnapshot(cfgSnap *proxycfg.ConfigSnapshot, token st
|
|
|
|
|
|
|
|
|
|
// clustersFromSnapshot returns the xDS API representation of the "clusters"
|
|
|
|
|
// (upstreams) in the snapshot.
|
|
|
|
|
func (s *Server) clustersFromSnapshotConnectProxy(cfgSnap *proxycfg.ConfigSnapshot, token string) ([]proto.Message, error) {
|
|
|
|
|
func (s *Server) clustersFromSnapshotConnectProxy(cfgSnap *proxycfg.ConfigSnapshot) ([]proto.Message, error) {
|
|
|
|
|
// TODO(rb): this sizing is a low bound.
|
|
|
|
|
clusters := make([]proto.Message, 0, len(cfgSnap.Proxy.Upstreams)+1)
|
|
|
|
|
|
|
|
|
@ -112,7 +112,7 @@ func makeExposeClusterName(destinationPort int) string {
|
|
|
|
|
// clustersFromSnapshotMeshGateway returns the xDS API representation of the "clusters"
|
|
|
|
|
// for a mesh gateway. This will include 1 cluster per remote datacenter as well as
|
|
|
|
|
// 1 cluster for each service subset.
|
|
|
|
|
func (s *Server) clustersFromSnapshotMeshGateway(cfgSnap *proxycfg.ConfigSnapshot, token string) ([]proto.Message, error) {
|
|
|
|
|
func (s *Server) clustersFromSnapshotMeshGateway(cfgSnap *proxycfg.ConfigSnapshot) ([]proto.Message, error) {
|
|
|
|
|
datacenters := cfgSnap.MeshGateway.Datacenters()
|
|
|
|
|
|
|
|
|
|
// 1 cluster per remote dc + 1 cluster per local service (this is a lower bound - all subset specific clusters will be appended)
|
|
|
|
|