Documentation ¶
Index ¶
- Variables
- func GetPortHTTP(service *model.Service) *model.Port
- func MakeExternalHTTPSService(hostname, external string, address string) *model.Service
- func MakeExternalHTTPService(hostname, external string, address string) *model.Service
- func MakeIP(service *model.Service, version int) string
- func MakeInstance(service *model.Service, port *model.Port, version int, az string) *model.ServiceInstance
- func MakeService(hostname, address string) *model.Service
- type ServiceDiscovery
- func (sd *ServiceDiscovery) AddService(name string, svc *model.Service)
- func (sd *ServiceDiscovery) ClearErrors()
- func (sd *ServiceDiscovery) GetIstioServiceAccounts(hostname string, ports []string) []string
- func (sd *ServiceDiscovery) GetProxyServiceInstances(node *model.Proxy) ([]*model.ServiceInstance, error)
- func (sd *ServiceDiscovery) GetService(hostname string) (*model.Service, error)
- func (sd *ServiceDiscovery) Instances(hostname string, ports []string, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
- func (sd *ServiceDiscovery) ManagementPorts(addr string) model.PortList
- func (sd *ServiceDiscovery) Services() ([]*model.Service, error)
Constants ¶
This section is empty.
Variables ¶
var ( PortHTTPName = "http" // Mock values HelloService = MakeService("hello.default.svc.cluster.local", "10.1.0.0") WorldService = MakeService("world.default.svc.cluster.local", "10.2.0.0") ExtHTTPService = MakeExternalHTTPService("httpbin.default.svc.cluster.local", "httpbin.org", "") ExtHTTPSService = MakeExternalHTTPSService("httpsbin.default.svc.cluster.local", "httpbin.org", "") Discovery = &ServiceDiscovery{ services: map[string]*model.Service{ HelloService.Hostname: HelloService, WorldService.Hostname: WorldService, ExtHTTPService.Hostname: ExtHTTPService, ExtHTTPSService.Hostname: ExtHTTPSService, }, versions: 2, } HelloInstanceV0 = MakeIP(HelloService, 0) HelloInstanceV1 = MakeIP(HelloService, 1) HelloProxyV0 = model.Proxy{ Type: model.Sidecar, IPAddress: HelloInstanceV0, ID: "v0.default", Domain: "default.svc.cluster.local", } HelloProxyV1 = model.Proxy{ Type: model.Sidecar, IPAddress: HelloInstanceV1, ID: "v1.default", Domain: "default.svc.cluster.local", } Ingress = model.Proxy{ Type: model.Ingress, IPAddress: "10.3.3.3", ID: "ingress.default", Domain: "default.svc.cluster.local", } )
Functions ¶
func GetPortHTTP ¶
GetPortHTTP returns the port which name is PortHTTPName. Returns nil if such a port does not exist (should not happenen if service is create via mock MakeSericve)
func MakeExternalHTTPSService ¶
MakeExternalHTTPSService creates mock external service
func MakeExternalHTTPService ¶
MakeExternalHTTPService creates mock external service
func MakeInstance ¶
func MakeInstance(service *model.Service, port *model.Port, version int, az string) *model.ServiceInstance
MakeInstance creates a mock instance, version enumerates endpoints
func MakeService ¶
MakeService creates a mock service
Types ¶
type ServiceDiscovery ¶
type ServiceDiscovery struct { WantGetProxyServiceInstances []*model.ServiceInstance ServicesError error GetServiceError error InstancesError error GetProxyServiceInstancesError error // contains filtered or unexported fields }
ServiceDiscovery is a mock discovery interface
func NewDiscovery ¶
func NewDiscovery(services map[string]*model.Service, versions int) *ServiceDiscovery
NewDiscovery builds a mock ServiceDiscovery
func (*ServiceDiscovery) AddService ¶
func (sd *ServiceDiscovery) AddService(name string, svc *model.Service)
func (*ServiceDiscovery) ClearErrors ¶
func (sd *ServiceDiscovery) ClearErrors()
ClearErrors clear errors used for mocking failures during model.ServiceDiscovery interface methods
func (*ServiceDiscovery) GetIstioServiceAccounts ¶
func (sd *ServiceDiscovery) GetIstioServiceAccounts(hostname string, ports []string) []string
GetIstioServiceAccounts gets the Istio service accounts for a service hostname.
func (*ServiceDiscovery) GetProxyServiceInstances ¶
func (sd *ServiceDiscovery) GetProxyServiceInstances(node *model.Proxy) ([]*model.ServiceInstance, error)
GetProxyServiceInstances implements discovery interface
func (*ServiceDiscovery) GetService ¶
func (sd *ServiceDiscovery) GetService(hostname string) (*model.Service, error)
GetService implements discovery interface
func (*ServiceDiscovery) Instances ¶
func (sd *ServiceDiscovery) Instances(hostname string, ports []string, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
Instances implements discovery interface
func (*ServiceDiscovery) ManagementPorts ¶
func (sd *ServiceDiscovery) ManagementPorts(addr string) model.PortList
ManagementPorts implements discovery interface