@ -470,18 +470,22 @@ func (s *state) handleUpdate(u cache.UpdateEvent, snap *ConfigSnapshot) error {
}
func ( s * state ) handleUpdateConnectProxy ( u cache . UpdateEvent , snap * ConfigSnapshot ) error {
if u . Err != nil {
return fmt . Errorf ( "error filling agent cache: %v" , u . Err )
}
switch {
case u . CorrelationID == rootsWatchID :
roots , ok := u . Result . ( * structs . IndexedCARoots )
if ! ok {
return fmt . Errorf ( "invalid type for roots r esponse: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
snap . Roots = roots
case u . CorrelationID == leafWatchID :
leaf , ok := u . Result . ( * structs . IssuedCert )
if ! ok {
return fmt . Errorf ( "invalid type for leaf response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
snap . ConnectProxy . Leaf = leaf
@ -491,7 +495,7 @@ func (s *state) handleUpdateConnectProxy(u cache.UpdateEvent, snap *ConfigSnapsh
case strings . HasPrefix ( u . CorrelationID , "discovery-chain:" ) :
resp , ok := u . Result . ( * structs . DiscoveryChainResponse )
if ! ok {
return fmt . Errorf ( "invalid type for service response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
svc := strings . TrimPrefix ( u . CorrelationID , "discovery-chain:" )
snap . ConnectProxy . DiscoveryChain [ svc ] = resp . Chain
@ -503,7 +507,7 @@ func (s *state) handleUpdateConnectProxy(u cache.UpdateEvent, snap *ConfigSnapsh
case strings . HasPrefix ( u . CorrelationID , "upstream-target:" ) :
resp , ok := u . Result . ( * structs . IndexedCheckServiceNodes )
if ! ok {
return fmt . Errorf ( "invalid type for service response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
correlationID := strings . TrimPrefix ( u . CorrelationID , "upstream-target:" )
targetID , svc , ok := removeColonPrefix ( correlationID )
@ -521,7 +525,7 @@ func (s *state) handleUpdateConnectProxy(u cache.UpdateEvent, snap *ConfigSnapsh
case strings . HasPrefix ( u . CorrelationID , "mesh-gateway:" ) :
resp , ok := u . Result . ( * structs . IndexedCheckServiceNodes )
if ! ok {
return fmt . Errorf ( "invalid type for service response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
correlationID := strings . TrimPrefix ( u . CorrelationID , "mesh-gateway:" )
dc , svc , ok := removeColonPrefix ( correlationID )
@ -538,7 +542,7 @@ func (s *state) handleUpdateConnectProxy(u cache.UpdateEvent, snap *ConfigSnapsh
case strings . HasPrefix ( u . CorrelationID , "upstream:" + serviceIDPrefix ) :
resp , ok := u . Result . ( * structs . IndexedCheckServiceNodes )
if ! ok {
return fmt . Errorf ( "invalid type for service response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
svc := strings . TrimPrefix ( u . CorrelationID , "upstream:" + serviceIDPrefix )
snap . ConnectProxy . UpstreamEndpoints [ svc ] = resp . Nodes
@ -546,7 +550,7 @@ func (s *state) handleUpdateConnectProxy(u cache.UpdateEvent, snap *ConfigSnapsh
case strings . HasPrefix ( u . CorrelationID , "upstream:" + preparedQueryIDPrefix ) :
resp , ok := u . Result . ( * structs . PreparedQueryExecuteResponse )
if ! ok {
return fmt . Errorf ( "invalid type for prepared query response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
pq := strings . TrimPrefix ( u . CorrelationID , "upstream:" )
snap . ConnectProxy . UpstreamEndpoints [ pq ] = resp . Nodes
@ -560,7 +564,7 @@ func (s *state) handleUpdateConnectProxy(u cache.UpdateEvent, snap *ConfigSnapsh
snap . ConnectProxy . WatchedServiceChecks [ svcID ] = resp
default :
return errors . New ( "unknown correlation ID" )
return fmt . Errorf ( "unknown correlation ID: %s " , u . CorrelationID )
}
return nil
}
@ -668,17 +672,21 @@ func (s *state) resetWatchesFromChain(
}
func ( s * state ) handleUpdateMeshGateway ( u cache . UpdateEvent , snap * ConfigSnapshot ) error {
if u . Err != nil {
return fmt . Errorf ( "error filling agent cache: %v" , u . Err )
}
switch u . CorrelationID {
case rootsWatchID :
roots , ok := u . Result . ( * structs . IndexedCARoots )
if ! ok {
return fmt . Errorf ( "invalid type for roots r esponse: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
snap . Roots = roots
case serviceListWatchID :
services , ok := u . Result . ( * structs . IndexedServices )
if ! ok {
return fmt . Errorf ( "invalid type for services response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
for svcName := range services . Services {
@ -721,7 +729,7 @@ func (s *state) handleUpdateMeshGateway(u cache.UpdateEvent, snap *ConfigSnapsho
case datacentersWatchID :
datacentersRaw , ok := u . Result . ( * [ ] string )
if ! ok {
return fmt . Errorf ( "invalid type for datacenters response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
if datacentersRaw == nil {
return fmt . Errorf ( "invalid response with a nil datacenter list" )
@ -771,7 +779,7 @@ func (s *state) handleUpdateMeshGateway(u cache.UpdateEvent, snap *ConfigSnapsho
case serviceResolversWatchID :
configEntries , ok := u . Result . ( * structs . IndexedConfigEntries )
if ! ok {
return fmt . Errorf ( "invalid type for services response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
resolvers := make ( map [ string ] * structs . ServiceResolverConfigEntry )
@ -786,7 +794,7 @@ func (s *state) handleUpdateMeshGateway(u cache.UpdateEvent, snap *ConfigSnapsho
case strings . HasPrefix ( u . CorrelationID , "connect-service:" ) :
resp , ok := u . Result . ( * structs . IndexedCheckServiceNodes )
if ! ok {
return fmt . Errorf ( "invalid type for service response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
svc := strings . TrimPrefix ( u . CorrelationID , "connect-service:" )
@ -799,7 +807,7 @@ func (s *state) handleUpdateMeshGateway(u cache.UpdateEvent, snap *ConfigSnapsho
case strings . HasPrefix ( u . CorrelationID , "mesh-gateway:" ) :
resp , ok := u . Result . ( * structs . IndexedCheckServiceNodes )
if ! ok {
return fmt . Errorf ( "invalid type for service response: %T" , u . Result )
return fmt . Errorf ( "invalid type for response: %T" , u . Result )
}
dc := strings . TrimPrefix ( u . CorrelationID , "mesh-gateway:" )