istio: Index | Files

package mock

import ""


Package Files

discovery.go discovery_mock.go


var (
    // PortHTTPName is the HTTP port name
    PortHTTPName = "http"

    // Locality for mock endpoints
    Locality = model.Locality{
        Label:     "region/zone",
        ClusterID: "",
var (
    // HelloService is a mock service with `hello.default.svc.cluster.local` as
    // a hostname and `` for ip
    HelloService = MakeService("hello.default.svc.cluster.local", "", []string{})

    // ReplicatedFooServiceName is a service replicated in all clusters.
    ReplicatedFooServiceName = host.Name("foo.default.svc.cluster.local")
    ReplicatedFooServiceV1   = MakeService(ReplicatedFooServiceName, "", []string{
    ReplicatedFooServiceV2 = MakeService(ReplicatedFooServiceName, "", []string{

    // WorldService is a mock service with `world.default.svc.cluster.local` as
    // a hostname and `` for ip
    WorldService = MakeService("world.default.svc.cluster.local", "", []string{

    // ExtHTTPService is a mock external HTTP service
    ExtHTTPService = MakeExternalHTTPService("httpbin.default.svc.cluster.local",
        true, "")

    // ExtHTTPSService is a mock external HTTPS service
    ExtHTTPSService = MakeExternalHTTPSService("httpsbin.default.svc.cluster.local",
        true, "")

    // HelloInstanceV0 is a mock IP address for v0 of HelloService
    HelloInstanceV0 = MakeIP(HelloService, 0)

    // HelloProxyV0 is a mock proxy v0 of HelloService
    HelloProxyV0 = model.Proxy{
        Type:         model.SidecarProxy,
        IPAddresses:  []string{HelloInstanceV0},
        ID:           "v0.default",
        DNSDomain:    "default.svc.cluster.local",
        IstioVersion: model.MaxIstioVersion,
        Metadata:     &model.NodeMetadata{},

    // MockDiscovery is an in-memory ServiceDiscover with mock services
    MockDiscovery = &ServiceDiscovery{
        services: map[host.Name]*model.Service{
            HelloService.Hostname:   HelloService,
            WorldService.Hostname:   WorldService,
            ExtHTTPService.Hostname: ExtHTTPService,

            ExtHTTPSService.Hostname: ExtHTTPSService,
        versions: 2,

func MakeExternalHTTPSService Uses

func MakeExternalHTTPSService(hostname host.Name, isMeshExternal bool, address string) *model.Service

MakeExternalHTTPSService creates memory external service

func MakeExternalHTTPService Uses

func MakeExternalHTTPService(hostname host.Name, isMeshExternal bool, address string) *model.Service

MakeExternalHTTPService creates memory external service

func MakeIP Uses

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

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

func MakeService Uses

func MakeService(hostname host.Name, address string, serviceAccounts []string) *model.Service

MakeService creates a memory service

type Controller Uses

type Controller struct{}

func (*Controller) AppendServiceHandler Uses

func (c *Controller) AppendServiceHandler(f func(*model.Service, model.Event))

func (*Controller) AppendWorkloadHandler Uses

func (c *Controller) AppendWorkloadHandler(f func(*model.WorkloadInstance, model.Event))

func (*Controller) HasSynced Uses

func (c *Controller) HasSynced() bool

func (*Controller) Run Uses

func (c *Controller) Run(<-chan struct{})

type ServiceDiscovery Uses

type ServiceDiscovery struct {
    WantGetProxyServiceInstances  []*model.ServiceInstance
    ServicesError                 error
    GetServiceError               error
    GetProxyServiceInstancesError error
    // contains filtered or unexported fields

ServiceDiscovery is a memory discovery interface

func NewDiscovery Uses

func NewDiscovery(services map[host.Name]*model.Service, versions int) *ServiceDiscovery

NewDiscovery builds a memory ServiceDiscovery

func (*ServiceDiscovery) GetIstioServiceAccounts Uses

func (sd *ServiceDiscovery) GetIstioServiceAccounts(svc *model.Service, ports []int) []string

GetIstioServiceAccounts gets the Istio service accounts for a service hostname.

func (*ServiceDiscovery) GetProxyServiceInstances Uses

func (sd *ServiceDiscovery) GetProxyServiceInstances(node *model.Proxy) []*model.ServiceInstance

GetProxyServiceInstances implements discovery interface

func (*ServiceDiscovery) GetProxyWorkloadLabels Uses

func (sd *ServiceDiscovery) GetProxyWorkloadLabels(proxy *model.Proxy) labels.Collection

func (*ServiceDiscovery) GetService Uses

func (sd *ServiceDiscovery) GetService(hostname host.Name) (*model.Service, error)

GetService implements discovery interface

func (*ServiceDiscovery) InstancesByPort Uses

func (sd *ServiceDiscovery) InstancesByPort(svc *model.Service, num int, labels labels.Collection) []*model.ServiceInstance

InstancesByPort implements discovery interface

func (*ServiceDiscovery) NetworkGateways Uses

func (sd *ServiceDiscovery) NetworkGateways() map[string][]*model.Gateway

func (*ServiceDiscovery) Services Uses

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

Services implements discovery interface

Package mock imports 7 packages (graph) and is imported by 2 packages. Updated 2020-11-26. Refresh now. Tools for package owners.