// FindByHostname finds a resource by its hostname and returns it.
173699
func (r *resourceRepository) FindByHostname(ctx context.Context, hostname string) (*resources.Resource, error) {
	r.mtx.RLock()
	defer r.mtx.RUnlock()
	resource, ok := r.resources[resourceHostname(hostname)]
	if !ok {
		return nil, resources.WithErrNotFound(errors.New("resource resource not found"))
	}
	return resource, nil
}
1092464
func Hostname() string {
	hostname := os.Getenv("HOSTNAME")
	if len(hostname) > 0 {
		return hostname
	}
	hostname, err := os.Hostname()
	if err == nil {
		return hostname
	}
	return "localhost"
}
73960
func (sl *Slack) FindGroupByName(name string) (*Group, error) {
	return sl.FindGroup(func(group *Group) bool {
		return group.Name == name
	})
}
292168
func (c *Client) Hostname() (string, error) {
	var hostname string
	err := c.doGet("hostname", func(r io.Reader) error {
		hostnameraw, err := ioutil.ReadAll(r)
		hostname = string(hostnameraw)
		return err
	})
	return hostname, err
}
49446
func (s *Application) FindModuleByDomain(host string) (*Module, bool) {
	module, has := s.moduleHosts[host]
	if !has {
		if p := strings.LastIndexByte(host, ':'); p > -1 {
			module, has = s.moduleHosts[host[0:p]]
		}
	}
	return module, has
}
543451
func TypeByName(typeName string) Type {
	initOnce.Do(discoverTypes)
	return Type2(types[typeName])
}
582180
func GetEndpointByName(endpointName string) (*HostComputeEndpoint, error) {
	hcnQuery := defaultQuery()
	mapA := map[string]string{"Name": endpointName}
	filter, err := json.Marshal(mapA)
	if err != nil {
		return nil, err
	}
	hcnQuery.Filter = string(filter)

	endpoints, err := ListEndpointsQuery(hcnQuery)
	if err != nil {
		return nil, err
	}
	if len(endpoints) == 0 {
		return nil, EndpointNotFoundError{EndpointName: endpointName}
	}
	return &endpoints[0], err
}
595119
func (r Spec) Hostname() string {
	i := strings.Index(r.Locator, "/")

	if i < 0 {
		i = len(r.Locator) + 1
	}
	return r.Locator[:i]
}
5335
func (s *Service) FindBucketByName(ctx context.Context, orgID influxdb.ID, n string) (*influxdb.Bucket, error) {
	span, ctx := tracing.StartSpanFromContext(ctx)
	defer span.Finish()

	var b *influxdb.Bucket
	var err error

	err = s.kv.View(ctx, func(tx Tx) error {
		bkt, pe := s.findBucketByName(ctx, tx, orgID, n)
		if pe != nil {
			err = pe
			return err
		}
		b = bkt
		return nil
	})

	return b, err
}
97915
func (a *API) GetDomainByName(name string) (*Domain, error) {
	domains, err := a.FindDomains(fmt.Sprintf("name eq \"%s\"", name))
	if err != nil {
		return nil, err
	}

	if len(domains) == 0 {
		return nil, ErrNotFound
	}

	if len(domains) > 1 {
		return nil, fmt.Errorf("name %q matched too many domains. please contact nimbusec.", name)
	}

	return &domains[0], nil
}
903900
func hostname() string {
	hostname, err := os.Hostname()
	if err != nil {
		return "unknown"
	}

	name, _ := parseHostname(hostname)
	return sanitizeHostname(name)
}
102846
func (c *Columns) FindByName(name string) *Column {
	for i, col := range c.columns {
		if col.Name == name {
			return c.columns[i]
		}
	}
	return nil
}
591926
func (s *partitionProcessor) findByName(partitionNames []model.CIStr, partitionName string) bool {
	for _, s := range partitionNames {
		if s.L == partitionName {
			return true
		}
	}
	return false
}
1327650
func (c *Cluster) GetNetworksByName(name string) ([]apitypes.NetworkResource, error) {
	// Note that swarmapi.GetNetworkRequest.Name is not functional.
	// So we cannot just use that with c.GetNetwork.
	return c.getNetworks(&swarmapi.ListNetworksRequest_Filters{
		Names: []string{name},
	})
}
707703
func NewHostname(domain, ip string, enabled bool) (*Hostname, error) {
	if !LooksLikeIPv4(ip) && !LooksLikeIPv6(ip) {
		return nil, fmt.Errorf("Unable to parse IP address %q", ip)
	}
	IP := net.ParseIP(ip)
	return &Hostname{domain, IP, enabled, LooksLikeIPv6(ip)}, nil
}
224070
func (g *Cloud) findDiskByName(diskName string, zone string) (*Disk, error) {
	mc := newDiskMetricContextZonal("get", g.region, zone)
	disk, err := g.manager.GetDiskFromCloudProvider(zone, diskName)
	if err == nil {
		return disk, mc.Observe(nil)
	}
	if !isHTTPErrorCode(err, http.StatusNotFound) {
		return nil, mc.Observe(err)
	}
	return nil, mc.Observe(nil)
}
609957
func (d *Domain) GetHostname(flags uint32) (string, error) {
	var err C.virError
	ret := C.virDomainGetHostnameWrapper(d.ptr, C.uint(flags), &err)
	if ret == nil {
		return "", makeError(&err)
	}

	defer C.free(unsafe.Pointer(ret))

	return C.GoString(ret), nil
}