// ParseEndpoints parses a Kubernetes Endpoints resource
428088
func ParseEndpoints(ep *types.Endpoints) (ServiceID, *Endpoints) {
	endpoints := newEndpoints()

	for _, sub := range ep.Subsets {
		for _, addr := range sub.Addresses {
			backend, ok := endpoints.Backends[addr.IP]
			if !ok {
				backend = service.PortConfiguration{}
				endpoints.Backends[addr.IP] = backend
			}

			for _, port := range sub.Ports {
				lbPort := loadbalancer.NewL4Addr(loadbalancer.L4Type(port.Protocol), uint16(port.Port))
				backend[port.Name] = lbPort
			}
		}
	}

	return ParseEndpointsID(ep), endpoints
}
1140661
func DeleteEndpoints(hostAddr string) error {
	// Get the state driver
	stateDriver, err := utils.GetStateDriver()
	if err != nil {
		return err
	}

	readEp := &mastercfg.CfgEndpointState{}
	readEp.StateDriver = stateDriver
	epCfgs, err := readEp.ReadAll()
	if err != nil {
		return err
	}

	for _, epCfg := range epCfgs {
		ep := epCfg.(*mastercfg.CfgEndpointState)
		nwCfg := &mastercfg.CfgNetworkState{}
		nwCfg.StateDriver = stateDriver
		err = nwCfg.Read(ep.NetID)
		if err != nil {
			log.Errorf("Network not found for NetID: %+v", ep.NetID)
			continue
		}

		netID := nwCfg.NetworkName + "." + nwCfg.Tenant
		epID := getEpName(netID, &intent.ConfigEP{Container: ep.EndpointID})
		if ep.HomingHost == hostAddr {
			log.Infof("Sending DeleteEndpoint for %+v", ep)
			_, err = DeleteEndpointID(stateDriver, epID)
			if err != nil {
				log.Errorf("Error delete endpoint: %+v. Err: %+v", ep, err)
			}
			epOper := &drivers.OperEndpointState{}
			epOper.StateDriver = stateDriver
			err := epOper.Read(epID)
			if err != nil {
				log.Errorf("Failed to read epOper: %+v", epOper)
				return err
			}
			err = epOper.Clear()
			if err != nil {
				log.Errorf("Error deleting oper state for %+v", epOper)
			} else {
				log.Infof("Deleted EP oper: %+v", epOper)
			}
		} else {
			log.Infof("EP not on host: %+v", hostAddr)
		}
	}

	return err
}
841202
func (p *BlockPuller) probeEndpoints(minRequestedSequence uint64) *endpointInfoBucket {
	endpointsInfo := make(chan *endpointInfo, len(p.Endpoints))

	var wg sync.WaitGroup
	wg.Add(len(p.Endpoints))

	var forbiddenErr uint32
	var unavailableErr uint32

	for _, endpoint := range p.Endpoints {
		go func(endpoint string) {
			defer wg.Done()
			ei, err := p.probeEndpoint(endpoint, minRequestedSequence)
			if err != nil {
				p.Logger.Warningf("Received error of type '%v' from %s", err, endpoint)
				if err == ErrForbidden {
					atomic.StoreUint32(&forbiddenErr, 1)
				}
				if err == ErrServiceUnavailable {
					atomic.StoreUint32(&unavailableErr, 1)
				}
				return
			}
			endpointsInfo <- ei
		}(endpoint)
	}
	wg.Wait()

	close(endpointsInfo)
	eib := &endpointInfoBucket{
		bucket: endpointsInfo,
		logger: p.Logger,
	}

	if unavailableErr == 1 && len(endpointsInfo) == 0 {
		eib.err = ErrServiceUnavailable
	}
	if forbiddenErr == 1 && len(endpointsInfo) == 0 {
		eib.err = ErrForbidden
	}
	return eib
}
1036176
func (o *InfrastructureAccessProfile) Connectionendpoints(info *bambou.FetchingInfo) (ConnectionendpointsList, *bambou.Error) {

	var list ConnectionendpointsList
	err := bambou.CurrentSession().FetchChildren(o, ConnectionendpointIdentity, &list, info)
	return list, err
}
937485
func NewContainerEndpoints(svc *service.Service, opts ContainerEndpointsOptions) (*ContainerEndpoints, error) {

	ce := &ContainerEndpoints{
		opts:  opts,
		ports: make(map[uint16]struct{}),
		vifs:  NewVIFRegistry(),
	}

	// load the state object
	allowDirect, err := ce.loadState(svc)
	if err != nil {
		return nil, err
	}

	// set up the proxy cache
	ce.cache = newProxyCache(opts.TenantID, opts.TCPMuxPort, opts.UseTLS, allowDirect)

	// set up virtual interface registry
	if err := ce.vifs.SetSubnet(opts.VirtualAddressSubnet); err != nil {
		return nil, err
	}

	return ce, nil
}
779989
func parseExtends(t *Tree, start Pos) (Node, error) {
	if t.Root().Parent != nil {
		return nil, newMultipleExtendsError(start)
	}
	tplRef, err := t.parseExpr()
	if err != nil {
		return nil, err
	}
	_, err = t.expect(tokenTagClose)
	if err != nil {
		return nil, err
	}
	n := NewExtendsNode(tplRef, start)
	t.Root().Parent = n
	return n, nil
}
1342723
func ValidateEndpoints(endpoints *api.Endpoints) validation.ErrorList {
	allErrs := ValidateObjectMeta(&endpoints.ObjectMeta, true, ValidateEndpointsName, validation.NewFieldPath("metadata"))
	allErrs = append(allErrs, validateEndpointSubsets(endpoints.Subsets, validation.NewFieldPath("subsets"))...)
	return allErrs
}
422347
func ParseEndpointConnectivity(epOptions map[string]interface{}) (*EndpointConnectivity, error) {
	if epOptions == nil {
		return nil, nil
	}

	ec := &EndpointConnectivity{}

	if opt, ok := epOptions[netlabel.PortMap]; ok {
		if bs, ok := opt.([]types.PortBinding); ok {
			ec.PortBindings = bs
		} else {
			return nil, fmt.Errorf("Invalid endpoint configuration")
		}
	}

	if opt, ok := epOptions[netlabel.ExposedPorts]; ok {
		if ports, ok := opt.([]types.TransportPort); ok {
			ec.ExposedPorts = ports
		} else {
			return nil, fmt.Errorf("Invalid endpoint configuration")
		}
	}
	return ec, nil
}
598787
func (g *Cloud) AttachNetworkEndpoints(name, zone string, endpoints []*computebeta.NetworkEndpoint) error {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newNetworkEndpointGroupMetricContext("attach", zone)
	req := &computebeta.NetworkEndpointGroupsAttachEndpointsRequest{
		NetworkEndpoints: endpoints,
	}
	return mc.Observe(g.c.BetaNetworkEndpointGroups().AttachNetworkEndpoints(ctx, meta.ZonalKey(name, zone), req))
}
675308
func GetRemotePeers(endpoints EndpointList) []string {
	peerSet := set.NewStringSet()
	for _, endpoint := range endpoints {
		if endpoint.Type() != URLEndpointType {
			continue
		}

		peer := endpoint.Host
		if endpoint.IsLocal {
			if _, port := mustSplitHostPort(peer); port == globalMinioPort {
				continue
			}
		}

		peerSet.Add(peer)
	}

	return peerSet.ToSlice()
}
85776
func (s *ciliumEndpointLister) CiliumEndpoints(namespace string) CiliumEndpointNamespaceLister {
	return ciliumEndpointNamespaceLister{indexer: s.indexer, namespace: namespace}
}
1173683
func (s *BrokerInstance) SetEndpoints(v []*string) *BrokerInstance {
	s.Endpoints = v
	return s
}
1271402
func (api *Client) GetDomainEndpoints(id string, query ...*GetDomainEndpointsQuery) ([]*DomainEndpoint, error) {
	var options *GetDomainEndpointsQuery
	if len(query) > 0 {
		options = query[0]
	}
	result, _, err := api.makeRequest(http.MethodGet, fmt.Sprintf("%s/%s/%s", api.concatUserPath(domainsPath), id, endpointsPath), &[]*DomainEndpoint{}, options)
	if err != nil {
		return nil, err
	}
	return *(result.(*[]*DomainEndpoint)), nil
}
1264954
func getEndpointsAndPort(endpoints []string) (endpointsR []string, portR int, err error) {
	var resultEndpoints []string
	var resultPort int

	if len(endpoints) > 1 {
		return nil, 0, ErrInvalidEndpointConfig
	}

	if len(endpoints[0]) > 0 {
		v := endpoints[0]

		if !strings.Contains(v, ":") {
			return nil, 0, ErrInvalidEndpointConfig
		}

		if strings.Contains(v, ",") {
			endpointsAndPort := strings.Split(v, ",")
			for _, val := range endpointsAndPort {
				endpointAndPort := strings.Split(val, ":")
				resultEndpoints = append(resultEndpoints, endpointAndPort[0])
				resultPort, err = strconv.Atoi(endpointAndPort[1])
				if err != nil {
					return nil, 0, err
				}
			}

		} else {
			endpointAndPort := strings.Split(v, ":")
			resultEndpoints = append(resultEndpoints, endpointAndPort[0])
			resultPort, err = strconv.Atoi(endpointAndPort[1])
			if err != nil {
				return nil, 0, err
			}
		}
	} else {
		return nil, 0, ErrInvalidEndpointConfig
	}

	return resultEndpoints, resultPort, nil
}
887110
func (c *clusterConnection) Endpoints() []string {
	c.mutex.RLock()
	defer c.mutex.RUnlock()

	var result []string
	for _, s := range c.servers {
		result = append(result, s.Endpoints()...)
	}
	return result
}
518820
func (s *StoreToEndpointsLister) GetServiceEndpoints(svc *api.Service) (ep api.Endpoints, err error) {
	for _, m := range s.Store.List() {
		ep = *m.(*api.Endpoints)
		if svc.Name == ep.Name && svc.Namespace == ep.Namespace {
			return ep, nil
		}
	}
	err = fmt.Errorf("could not find endpoints for service: %v", svc.Name)
	return
}
480185
func (s Service) Endpoints() map[string]Endpoint {
	es := map[string]Endpoint{}
	for id := range s.p.Services[s.id].Endpoints {
		es[id] = Endpoint{
			id:        id,
			serviceID: s.id,
			p:         s.p,
		}
	}

	return es
}