// ResolveAlias returns alias or error if not found
349637
func (ns *Namespace) ResolveAlias(nameNode node.Node, aliasType string) (string, error) {
	aliasType = strings.ToLower(aliasType)
	nameParts := nameNode.(*name.Name).Parts

	firstPartStr := nameParts[0].(*name.NamePart).Value

	if len(nameParts) > 1 { // resolve aliases for qualified names, always against class alias type
		firstPartStr = strings.ToLower(firstPartStr)
		aliasType = ""
	} else {
		if aliasType != "const" { // constants are case-sensitive
			firstPartStr = strings.ToLower(firstPartStr)
		}
	}

	aliasName, ok := ns.Aliases[aliasType][firstPartStr]
	if !ok {
		return "", errors.New("Not found")
	}

	return aliasName, nil
}
1150918
func (c *Client) ResolveServicePath(path string, noprefix bool) ([]service.ServiceDetails, error) {
	resolveServiceRequest := ResolveServiceRequest{
		Path: path,
		NoPrefix: noprefix,
	}
	svcs := []service.ServiceDetails{}

	plog.WithFields(logrus.Fields{
                "path": path,
                "noprefix": noprefix,
        }).Info("Trying to find service")

	err := c.call("ResolveServicePath", resolveServiceRequest, &svcs)
        return svcs, err
}
233927
func ValidateAlias(val string) (string, error) {
	if _, _, err := ParseAlias(val); err != nil {
		return val, err
	}
	return val, nil
}
628423
func (ns *Namespace) resolveArgs(args []interface{}) (resource.Resource, map[string]interface{}, error) {
	if len(args) == 0 {
		return nil, nil, errors.New("no Resource provided in transformation")
	}

	if len(args) == 1 {
		r, ok := args[0].(resource.Resource)
		if !ok {
			return nil, nil, fmt.Errorf("type %T not supported in Resource transformations", args[0])
		}
		return r, nil, nil
	}

	r, ok := args[1].(resource.Resource)
	if !ok {
		return nil, nil, fmt.Errorf("type %T not supported in Resource transformations", args[0])
	}

	m, err := cast.ToStringMapE(args[0])
	if err != nil {
		return nil, nil, _errors.Wrap(err, "invalid options type")
	}

	return r, m, nil
}
976091
func ResolveHome(path string) string {
	if path[:2] == "~/" {
		usr, _ := user.Current()
		dir := usr.HomeDir
		path = strings.Replace(path, "~/", dir, 1)
	}

	return path
}
288942
func (s *DescribeOrganizationOutput) SetAlias(v string) *DescribeOrganizationOutput {
	s.Alias = &v
	return s
}
556894
func (ns *Namespace) ResolveName(nameNode node.Node, aliasType string) (string, error) {
	switch n := nameNode.(type) {
	case *name.FullyQualified:
		// Fully qualifid name is already resolved
		return concatNameParts(n.Parts), nil

	case *name.Relative:
		if ns.Namespace == "" {
			return concatNameParts(n.Parts), nil
		}
		return ns.Namespace + "\\" + concatNameParts(n.Parts), nil

	case *name.Name:
		if aliasType == "const" && len(n.Parts) == 1 {
			part := strings.ToLower(n.Parts[0].(*name.NamePart).Value)
			if part == "true" || part == "false" || part == "null" {
				return part, nil
			}
		}

		if aliasType == "" && len(n.Parts) == 1 {
			part := strings.ToLower(n.Parts[0].(*name.NamePart).Value)

			switch part {
			case "self":
				fallthrough
			case "static":
				fallthrough
			case "parent":
				fallthrough
			case "int":
				fallthrough
			case "float":
				fallthrough
			case "bool":
				fallthrough
			case "string":
				fallthrough
			case "void":
				fallthrough
			case "iterable":
				fallthrough
			case "object":
				return part, nil
			}
		}

		aliasName, err := ns.ResolveAlias(nameNode, aliasType)
		if err != nil {
			// resolve as relative name if alias not found
			if ns.Namespace == "" {
				return concatNameParts(n.Parts), nil
			}
			return ns.Namespace + "\\" + concatNameParts(n.Parts), nil
		}

		if len(n.Parts) > 1 {
			// if name qualified, replace first part by alias
			return aliasName + "\\" + concatNameParts(n.Parts[1:]), nil
		}

		return aliasName, nil
	}

	return "", errors.New("must be instance of name.Names")
}
1066572
func (s *DistributionConfig) SetAliases(v *Aliases) *DistributionConfig {
	s.Aliases = v
	return s
}
838513
func (a *API) ResolveURI(ctx context.Context, uri *URI, credentials string) (storage.Address, error) {
	apiResolveCount.Inc(1)
	log.Trace("resolving", "uri", uri.Addr)

	var sp opentracing.Span
	ctx, sp = spancontext.StartSpan(
		ctx,
		"api.resolve")
	defer sp.Finish()

	// if the URI is immutable, check if the address looks like a hash
	if uri.Immutable() {
		key := uri.Address()
		if key == nil {
			return nil, fmt.Errorf("immutable address not a content hash: %q", uri.Addr)
		}
		return key, nil
	}

	addr, err := a.Resolve(ctx, uri.Addr)
	if err != nil {
		return nil, err
	}

	if uri.Path == "" {
		return addr, nil
	}
	walker, err := a.NewManifestWalker(ctx, addr, a.Decryptor(ctx, credentials), nil)
	if err != nil {
		return nil, err
	}
	var entry *ManifestEntry
	walker.Walk(func(e *ManifestEntry) error {
		// if the entry matches the path, set entry and stop
		// the walk
		if e.Path == uri.Path {
			entry = e
			// return an error to cancel the walk
			return errors.New("found")
		}
		// ignore non-manifest files
		if e.ContentType != ManifestType {
			return nil
		}
		// if the manifest's path is a prefix of the
		// requested path, recurse into it by returning
		// nil and continuing the walk
		if strings.HasPrefix(uri.Path, e.Path) {
			return nil
		}
		return ErrSkipManifest
	})
	if entry == nil {
		return nil, errors.New("not found")
	}
	addr = storage.Address(common.Hex2Bytes(entry.Hash))
	return addr, nil
}
155446
func (s *DistributionSummary) SetAliases(v *Aliases) *DistributionSummary {
	s.Aliases = v
	return s
}
74961
func GetAlias(ctx context.Context) string {
	a, ok := ctx.Value(ctxKeyAlias).(string)
	if !ok {
		return ""
	}
	return a
}
193860
func (s *IndicesRolloverService) Alias(alias string) *IndicesRolloverService {
	s.alias = alias
	return s
}
1107108
func (b *Builder) replaceAliases(input string) string {
	replaced := []string{}
	for _, arg := range strings.Split(input, ",") {
		if aliases, ok := b.mapper.AliasesForResource(arg); ok {
			arg = strings.Join(aliases, ",")
		}
		replaced = append(replaced, arg)
	}
	return strings.Join(replaced, ",")
}
298695
func (s *CreateAliasInput) SetAlias(v string) *CreateAliasInput {
	s.Alias = &v
	return s
}
854552
func NameAlias(name string) (string, string) {
	parts := strings.SplitN(name, ":", 2)
	if len(parts) == 2 {
		return parts[0], parts[1]
	}
	return parts[0], parts[0]
}
108165
func (c *Client) ResolveCharms(args params.ResolveCharms) (params.ResolveCharmResults, error) {
	if err := c.checkCanWrite(); err != nil {
		return params.ResolveCharmResults{}, err
	}

	shim := application.NewStateShim(c.api.state())
	return application.ResolveCharms(shim, args)
}
1107819
func ResolveURL(scheme string, addr string) string {
	host := ResolveVHost(addr)
	return scheme + "://" + host
}