mock

package
v0.0.0-...-062eff5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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[model.Hostname]*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

func GetPortHTTP(service *model.Service) *model.Port

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

func MakeExternalHTTPSService(hostname, external model.Hostname, address string) *model.Service

MakeExternalHTTPSService creates mock external service

func MakeExternalHTTPService

func MakeExternalHTTPService(hostname, external model.Hostname, address string) *model.Service

MakeExternalHTTPService creates mock external service

func MakeIP

func MakeIP(service *model.Service, version int) string

MakeIP creates a fake IP address for a service and instance version

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

func MakeService(hostname model.Hostname, address string) *model.Service

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[model.Hostname]*model.Service, versions int) *ServiceDiscovery

NewDiscovery builds a mock ServiceDiscovery

func (*ServiceDiscovery) AddService

func (sd *ServiceDiscovery) AddService(name model.Hostname, 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 model.Hostname, 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 model.Hostname) (*model.Service, error)

GetService implements discovery interface

func (*ServiceDiscovery) Instances

func (sd *ServiceDiscovery) Instances(hostname model.Hostname, ports []string,
	labels model.LabelsCollection) ([]*model.ServiceInstance, error)

Instances implements discovery interface

func (*ServiceDiscovery) InstancesByPort

func (sd *ServiceDiscovery) InstancesByPort(hostname model.Hostname, num int,
	labels model.LabelsCollection) ([]*model.ServiceInstance, error)

InstancesByPort implements discovery interface

func (*ServiceDiscovery) ManagementPorts

func (sd *ServiceDiscovery) ManagementPorts(addr string) model.PortList

ManagementPorts implements discovery interface

func (*ServiceDiscovery) Services

func (sd *ServiceDiscovery) Services() ([]*model.Service, error)

Services implements discovery interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL