2022-06-01 15:18:06 +00:00
|
|
|
package proxycfg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
cachetype "github.com/hashicorp/consul/agent/cache-types"
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
2022-06-01 21:53:52 +00:00
|
|
|
"github.com/hashicorp/consul/proto/pbpeering"
|
2022-06-01 15:18:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// UpdateEvent contains new data for a resource we are subscribed to (e.g. an
|
|
|
|
// agent cache entry).
|
|
|
|
type UpdateEvent struct {
|
|
|
|
CorrelationID string
|
|
|
|
Result interface{}
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
// DataSources contains the dependencies used to consume data used to configure
|
|
|
|
// proxies.
|
|
|
|
type DataSources struct {
|
|
|
|
// CARoots provides updates about the CA root certificates on a notification
|
|
|
|
// channel.
|
|
|
|
CARoots CARoots
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// CompiledDiscoveryChain provides updates about a service's discovery chain
|
|
|
|
// on a notification channel.
|
|
|
|
CompiledDiscoveryChain CompiledDiscoveryChain
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// ConfigEntry provides updates about a single config entry on a notification
|
|
|
|
// channel.
|
|
|
|
ConfigEntry ConfigEntry
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// ConfigEntryList provides updates about a list of config entries on a
|
|
|
|
// notification channel.
|
|
|
|
ConfigEntryList ConfigEntryList
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// Datacenters provides updates about federated datacenters on a notification
|
|
|
|
// channel.
|
|
|
|
Datacenters Datacenters
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// FederationStateListMeshGateways is the interface used to consume updates
|
|
|
|
// about mesh gateways from the federation state.
|
|
|
|
FederationStateListMeshGateways FederationStateListMeshGateways
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// GatewayServices provides updates about a gateway's upstream services on a
|
|
|
|
// notification channel.
|
|
|
|
GatewayServices GatewayServices
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// Health provides service health updates on a notification channel.
|
|
|
|
Health Health
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// HTTPChecks provides updates about a service's HTTP and gRPC checks on a
|
|
|
|
// notification channel.
|
|
|
|
HTTPChecks HTTPChecks
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// Intentions provides intention updates on a notification channel.
|
|
|
|
Intentions Intentions
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// IntentionUpstreams provides intention-inferred upstream updates on a
|
|
|
|
// notification channel.
|
|
|
|
IntentionUpstreams IntentionUpstreams
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// InternalServiceDump provides updates about a (gateway) service on a
|
|
|
|
// notification channel.
|
|
|
|
InternalServiceDump InternalServiceDump
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// LeafCertificate provides updates about the service's leaf certificate on a
|
|
|
|
// notification channel.
|
|
|
|
LeafCertificate LeafCertificate
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-07-13 16:14:57 +00:00
|
|
|
// PeeredUpstreams provides imported-service upstream updates on a
|
|
|
|
// notification channel.
|
2022-06-29 20:34:58 +00:00
|
|
|
PeeredUpstreams PeeredUpstreams
|
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// PreparedQuery provides updates about the results of a prepared query.
|
|
|
|
PreparedQuery PreparedQuery
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// ResolvedServiceConfig provides updates about a service's resolved config.
|
|
|
|
ResolvedServiceConfig ResolvedServiceConfig
|
2022-06-01 21:53:52 +00:00
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// ServiceList provides updates about the list of all services in a datacenter
|
|
|
|
// on a notification channel.
|
|
|
|
ServiceList ServiceList
|
|
|
|
|
2022-06-01 21:53:52 +00:00
|
|
|
// TrustBundle provides updates about the trust bundle for a single peer.
|
|
|
|
TrustBundle TrustBundle
|
|
|
|
|
2022-06-01 20:31:37 +00:00
|
|
|
// TrustBundleList provides updates about the list of trust bundles for
|
|
|
|
// peered clusters that the given proxy is exported to.
|
|
|
|
TrustBundleList TrustBundleList
|
|
|
|
|
2022-06-06 19:20:41 +00:00
|
|
|
// ExportedPeeredServices provides updates about the list of all exported
|
|
|
|
// services in a datacenter on a notification channel.
|
|
|
|
ExportedPeeredServices ExportedPeeredServices
|
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
DataSourcesEnterprise
|
|
|
|
}
|
|
|
|
|
|
|
|
// CARoots is the interface used to consume updates about the CA root
|
|
|
|
// certificates.
|
|
|
|
type CARoots interface {
|
|
|
|
Notify(ctx context.Context, req *structs.DCSpecificRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// CompiledDiscoveryChain is the interface used to consume updates about the
|
|
|
|
// compiled discovery chain for a service.
|
|
|
|
type CompiledDiscoveryChain interface {
|
|
|
|
Notify(ctx context.Context, req *structs.DiscoveryChainRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConfigEntry is the interface used to consume updates about a single config
|
|
|
|
// entry.
|
|
|
|
type ConfigEntry interface {
|
|
|
|
Notify(ctx context.Context, req *structs.ConfigEntryQuery, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConfigEntry is the interface used to consume updates about a list of config
|
|
|
|
// entries.
|
|
|
|
type ConfigEntryList interface {
|
|
|
|
Notify(ctx context.Context, req *structs.ConfigEntryQuery, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Datacenters is the interface used to consume updates about federated
|
|
|
|
// datacenters.
|
|
|
|
type Datacenters interface {
|
|
|
|
Notify(ctx context.Context, req *structs.DatacentersRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// FederationStateListMeshGateways is the interface used to consume updates
|
|
|
|
// about mesh gateways from the federation state.
|
|
|
|
type FederationStateListMeshGateways interface {
|
|
|
|
Notify(ctx context.Context, req *structs.DCSpecificRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// GatewayServices is the interface used to consume updates about a gateway's
|
|
|
|
// upstream services.
|
|
|
|
type GatewayServices interface {
|
|
|
|
Notify(ctx context.Context, req *structs.ServiceSpecificRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Health is the interface used to consume service health updates.
|
|
|
|
type Health interface {
|
|
|
|
Notify(ctx context.Context, req *structs.ServiceSpecificRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// HTTPChecks is the interface used to consume updates about a service's HTTP
|
|
|
|
// and gRPC-based checks (in order to determine which paths to expose through
|
|
|
|
// the proxy).
|
|
|
|
type HTTPChecks interface {
|
|
|
|
Notify(ctx context.Context, req *cachetype.ServiceHTTPChecksRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Intentions is the interface used to consume intention updates.
|
|
|
|
type Intentions interface {
|
2022-07-01 15:15:49 +00:00
|
|
|
Notify(ctx context.Context, req *structs.ServiceSpecificRequest, correlationID string, ch chan<- UpdateEvent) error
|
2022-06-01 15:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// IntentionUpstreams is the interface used to consume updates about upstreams
|
|
|
|
// inferred from service intentions.
|
|
|
|
type IntentionUpstreams interface {
|
|
|
|
Notify(ctx context.Context, req *structs.ServiceSpecificRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// InternalServiceDump is the interface used to consume updates about a (gateway)
|
|
|
|
// service via the internal ServiceDump RPC.
|
|
|
|
type InternalServiceDump interface {
|
|
|
|
Notify(ctx context.Context, req *structs.ServiceDumpRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// LeafCertificate is the interface used to consume updates about a service's
|
|
|
|
// leaf certificate.
|
|
|
|
type LeafCertificate interface {
|
|
|
|
Notify(ctx context.Context, req *cachetype.ConnectCALeafRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
2022-06-29 20:34:58 +00:00
|
|
|
// PeeredUpstreams is the interface used to consume updates about upstreams
|
|
|
|
// for all peered targets in a given partition.
|
|
|
|
type PeeredUpstreams interface {
|
|
|
|
Notify(ctx context.Context, req *structs.PartitionSpecificRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
2022-06-01 15:18:06 +00:00
|
|
|
// PreparedQuery is the interface used to consume updates about the results of
|
|
|
|
// a prepared query.
|
|
|
|
type PreparedQuery interface {
|
|
|
|
Notify(ctx context.Context, req *structs.PreparedQueryExecuteRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResolvedServiceConfig is the interface used to consume updates about a
|
|
|
|
// service's resolved config.
|
|
|
|
type ResolvedServiceConfig interface {
|
|
|
|
Notify(ctx context.Context, req *structs.ServiceConfigRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// ServiceList is the interface used to consume updates about the list of
|
|
|
|
// all services in a datacenter.
|
|
|
|
type ServiceList interface {
|
|
|
|
Notify(ctx context.Context, req *structs.DCSpecificRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
2022-06-01 21:53:52 +00:00
|
|
|
|
|
|
|
// TrustBundle is the interface used to consume updates about a single
|
|
|
|
// peer's trust bundle.
|
|
|
|
type TrustBundle interface {
|
|
|
|
Notify(ctx context.Context, req *pbpeering.TrustBundleReadRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
2022-06-01 20:31:37 +00:00
|
|
|
|
|
|
|
// TrustBundleList is the interface used to consume updates about trust bundles
|
|
|
|
// for peered clusters that the given proxy is exported to.
|
|
|
|
type TrustBundleList interface {
|
|
|
|
Notify(ctx context.Context, req *pbpeering.TrustBundleListByServiceRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|
2022-06-06 19:20:41 +00:00
|
|
|
|
|
|
|
// ExportedPeeredServices is the interface used to consume updates about the
|
|
|
|
// list of all services exported to peers in a datacenter.
|
|
|
|
type ExportedPeeredServices interface {
|
|
|
|
Notify(ctx context.Context, req *structs.DCSpecificRequest, correlationID string, ch chan<- UpdateEvent) error
|
|
|
|
}
|