// PortByName implements Switch interface
356264
func (s *Switch) PortByName(name string) (p *mech.SwitchPort, err error) {
	err = errors.New("switch: port does not exist")

	s.PortIter(func(port *mech.SwitchPort) (ok bool) {
		if ok = port.Name != name; !ok {
			p, err = port, nil

			log.DebugLog("switch/PORT_BY_NAME",
				"Found port by name: ", name)
		}

		return
	})

	if err != nil {
		log.ErrorLog("switch/SWITCH_BY_NAME",
			"Failed to find switch by name: ", name)
	}

	return
}
1101443
func (p *Pod) FindContainerByName(containerName string) *Container {
	for _, c := range p.Containers {
		if c.Name == containerName {
			return c
		}
	}
	return nil
}
1290753
func (api *BridgeAPI) SortByName(reverse bool) *BridgeAPI {
	api.sortByName(reverse)
	return api
}
1105535
func (api *ZoneAPI) SortByName(reverse bool) *ZoneAPI {
	api.sortByName(reverse)
	return api
}
1343688
func (c *Calcium) GetNodeByName(ctx context.Context, nodename string) (*types.Node, error) {
	return c.store.GetNodeByName(ctx, nodename)
}
351144
func (dns *dnsControl) GetNodeByName(name string) (*api.Node, error) {
	v1node, err := dns.client.CoreV1().Nodes().Get(name, meta.GetOptions{})
	return v1node, err
}
33791
func (r *Resource) MethodByName(name string) *Method {
	switch name {
	case "GET":
		return r.Get
	case "POST":
		return r.Post
	case "PUT":
		return r.Put
	case "PATCH":
		return r.Patch
	case "HEAD":
		return r.Head
	case "DELETE":
		return r.Delete
	case "OPTIONS":
		return r.Options
	default:
		return nil
	}
}
208129
func (m *Monitor) NodeByName(name string) (index int, node *Node) {
	m.mtx.Lock()
	defer m.mtx.Unlock()

	for i, n := range m.Nodes {
		if name == n.Name {
			return i, n
		}
	}
	return -1, nil
}
721299
func (api *DatabaseAPI) SortByName(reverse bool) *DatabaseAPI {
	api.sortByName(reverse)
	return api
}
54582
func (r Routes) FindRouteByName(name string) (Route, bool) {
	for _, route := range r {
		if route.Name == name {
			return route, true
		}
	}
	return Route{}, false
}
1319574
func LookupServicePortNumberByName(svc v1.Service, name string) (int32, error) {
	for _, svcportspec := range svc.Spec.Ports {
		if svcportspec.Name == name {
			return svcportspec.Port, nil
		}
	}

	return int32(-1), fmt.Errorf("Service '%s' does not have a named port '%s'", svc.Name, name)
}
1280724
func findPortByName(container v1.Container, portName string) (int, error) {
	for _, port := range container.Ports {
		if port.Name == portName {
			return int(port.ContainerPort), nil
		}
	}
	return 0, fmt.Errorf("port %s not found", portName)
}
1076228
func (ps Params) ByName(name string) string {
	for i := range ps {
		if ps[i].Key == name {
			return ps[i].Value
		}
	}
	return ""
}
413955
func (m *BaseMechanismManager) DisableByName(name string) error {
	mechanism, ok := m.Mechanisms.Get(name)
	if !ok {
		return ErrMechanismNotRegistered
	}

	if !mechanism.Enabled() {
		return nil
	}

	mechanism.Disable()
	atomic.StoreInt64(&m.activated, 0)
	atomic.StoreInt64(&m.enabled, 0)

	return nil
}
981405
func (api *VPCRouterAPI) SortByName(reverse bool) *VPCRouterAPI {
	api.sortByName(reverse)
	return api
}
147519
func ModuleByName(name string) (*Module, bool) {
	// If the name ends with the namespace separator remove it
	if name[len(name)-1] == []byte(namespaceSeperator)[0] {
		name = name[:len(name)-1]
	}
	name = strings.ToLower(name)
	if name == strings.ToLower(appModule.Name) {
		return appModule, true
	}
	for _, module := range Modules {
		if strings.ToLower(module.Name) == name {
			return module, true
		}
	}
	return nil, false
}
543451
func TypeByName(typeName string) Type {
	initOnce.Do(discoverTypes)
	return Type2(types[typeName])
}