// Resolve resolves dependencies and returns a lock file with the resolution.
485789
func (r *Resolver) Resolve(reqs *chartutil.Requirements, repoNames map[string]string, d string) (*chartutil.RequirementsLock, error) {

	// Now we clone the dependencies, locking as we go.
	locked := make([]*chartutil.Dependency, len(reqs.Dependencies))
	missing := []string{}
	for i, d := range reqs.Dependencies {
		if strings.HasPrefix(d.Repository, "file://") {

			if _, err := GetLocalPath(d.Repository, r.chartpath); err != nil {
				return nil, err
			}

			locked[i] = &chartutil.Dependency{
				Name:       d.Name,
				Repository: d.Repository,
				Version:    d.Version,
			}
			continue
		}
		constraint, err := semver.NewConstraint(d.Version)
		if err != nil {
			return nil, fmt.Errorf("dependency %q has an invalid version/constraint format: %s", d.Name, err)
		}

		repoIndex, err := repo.LoadIndexFile(r.helmhome.CacheIndex(repoNames[d.Name]))
		if err != nil {
			return nil, fmt.Errorf("no cached repo found. (try 'helm repo update'). %s", err)
		}

		vs, ok := repoIndex.Entries[d.Name]
		if !ok {
			return nil, fmt.Errorf("%s chart not found in repo %s", d.Name, d.Repository)
		}

		locked[i] = &chartutil.Dependency{
			Name:       d.Name,
			Repository: d.Repository,
		}
		found := false
		// The version are already sorted and hence the first one to satisfy the constraint is used
		for _, ver := range vs {
			v, err := semver.NewVersion(ver.Version)
			if err != nil || len(ver.URLs) == 0 {
				// Not a legit entry.
				continue
			}
			if constraint.Check(v) {
				found = true
				locked[i].Version = v.Original()
				break
			}
		}

		if !found {
			missing = append(missing, d.Name)
		}
	}
	if len(missing) > 0 {
		return nil, fmt.Errorf("Can't get a valid version for repositories %s. Try changing the version constraint in requirements.yaml", strings.Join(missing, ", "))
	}
	return &chartutil.RequirementsLock{
		Generated:    time.Now(),
		Digest:       d,
		Dependencies: locked,
	}, nil
}
179746
func (k *KeybaseServiceBase) Resolve(
	ctx context.Context, assertion string,
	offline keybase1.OfflineAvailability) (
	kbname.NormalizedUsername, keybase1.UserOrTeamID, error) {
	res, err := k.identifyClient.Resolve3(
		ctx, keybase1.Resolve3Arg{
			Assertion: assertion,
			Oa:        offline,
		})
	if err != nil {
		return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""),
			ConvertIdentifyError(assertion, err)
	}
	return kbname.NewNormalizedUsername(res.Name), res.Id, nil
}
367640
func (cr *ConflictResolver) Resolve(ctx context.Context,
	unmerged kbfsmd.Revision, merged kbfsmd.Revision) {
	cr.inputChanLock.RLock()
	defer cr.inputChanLock.RUnlock()

	// CR can end up trying to cancel itself via the SyncAll call, so
	// prevent that from happening.
	if crOpID := ctx.Value(CtxCRIDKey); crOpID != nil {
		cr.log.CDebugf(ctx, "Ignoring self-resolve during CR")
		return
	}

	if cr.inputChan == nil {
		return
	}

	// Call Add before cancelling existing CR in order to prevent the
	// resolveGroup from becoming briefly empty and allowing things waiting
	// on it to believe that CR has finished.
	cr.resolveGroup.Add(1)

	ci := conflictInput{unmerged, merged}
	func() {
		cr.inputLock.Lock()
		defer cr.inputLock.Unlock()
		// Cancel any running CR before we return, so the caller can be
		// confident any ongoing CR superseded by this new input will be
		// canceled before it releases any locks it holds.
		//
		// TODO: return early if this returns false, and log something
		// using a newly-pass-in context.
		_ = cr.cancelExistingLocked(ci)
	}()

	cr.inputChan <- ci
}
64791
func (sr *staticResolver) Resolve(target string) (naming.Watcher, error) {
	return sr, nil
}
1070606
func (t *Task) IsResolved() bool {
	t.resolvedMu.Lock()
	defer t.resolvedMu.Unlock()

	return t.resolved
}
1144637
func (r *PeerResolver) Resolve(peers []fab.Peer) (fab.Peer, error) {
	filteredPeers := r.blockHeightResolver.Filter(peers)

	var orgPeers []fab.Peer
	for _, p := range filteredPeers {
		if p.MSPID() == r.mspID {
			orgPeers = append(orgPeers, p)
		}
	}

	if len(orgPeers) > 0 {
		// Our org is in the list. Use the default balancer to balance between them.
		logger.Debugf("Choosing a peer from [%s]", r.mspID)
		return r.loadBalancePolicy.Choose(orgPeers)
	}

	logger.Debugf("Choosing a peer from another org since there are no peers from [%s] in the list of peers", r.mspID)
	return r.loadBalancePolicy.Choose(filteredPeers)
}
763630
func (r FirstMatchResolver) Resolve(value string) (*ComponentMatch, error) {
	matches, err := r.Searcher.Search(true, value)
	if len(matches) == 0 {
		return nil, ErrNoMatch{Value: value, Errs: err, Type: r.Searcher.Type()}
	}
	return matches[0], errors.NewAggregate(err)
}
894918
func (tab *Table) Resolve(n *enode.Node) *enode.Node {
	tab.mutex.Lock()
	cl := tab.closest(n.ID(), 1, false)
	tab.mutex.Unlock()
	if len(cl.entries) > 0 && cl.entries[0].ID() == n.ID() {
		return unwrapNode(cl.entries[0])
	}
	return nil
}
563264
func (r *dnsResolver) Resolve(target string) (Watcher, error) {
	host, port, err := parseTarget(target)
	if err != nil {
		return nil, err
	}

	if net.ParseIP(host) != nil {
		ipWatcher := &ipWatcher{
			updateChan: make(chan *Update, 1),
		}
		host, _ = formatIP(host)
		ipWatcher.updateChan <- &Update{Op: Add, Addr: host + ":" + port}
		return ipWatcher, nil
	}

	ctx, cancel := context.WithCancel(context.Background())
	return &dnsWatcher{
		r:      r,
		host:   host,
		port:   port,
		ctx:    ctx,
		cancel: cancel,
		t:      time.NewTimer(0),
	}, nil
}
1124040
func (r *Resolver) Resolve(qname, qtype string) RRs {
	rrs, err := r.ResolveErr(qname, qtype)
	if err == NXDOMAIN {
		return emptyRRs
	}
	if err != nil {
		return nil
	}
	return rrs
}
920847
func (w *Worklog) Resolve(ctx context.Context, n *observer.Notifier,
	orgID *identity.ID, ident *apitypes.WorklogID) error {

	item, err := w.Get(ctx, orgID, ident)
	if err != nil {
		return err
	}

	if item == nil {
		return nil
	}

	for t, h := range w.handlers {
		if t&item.Type() == 0 {
			continue
		}

		return h.resolve(ctx, n, orgID, item)
	}

	panic("worklog handler not found for type")
}
1287894
func (d DestinationKeyRange) Resolve(allShards []*topodatapb.ShardReference, addShard func(shard string) error) error {
	return processKeyRange(allShards, d.KeyRange, addShard)
}
113639
func (b *Block) resolve(ctx context.Context) (*types.Block, error) {
	if b.block != nil {
		return b.block, nil
	}

	var err error
	if b.hash != (common.Hash{}) {
		b.block, err = b.backend.GetBlock(ctx, b.hash)
	} else {
		b.block, err = b.backend.BlockByNumber(ctx, *b.num)
	}
	if b.block != nil {
		b.header = b.block.Header()
	}
	return b.block, err
}
164302
func (c *Client) Resolved(p params.Resolved) error {
	if err := c.checkCanWrite(); err != nil {
		return err
	}
	if err := c.check.ChangeAllowed(); err != nil {
		return errors.Trace(err)
	}
	unit, err := c.api.stateAccessor.Unit(p.UnitName)
	if err != nil {
		return err
	}
	return unit.Resolve(p.Retry)
}
1041066
func (state *Runtime) Resolve(name string) reflect.Value {

	if name == "." {
		return state.context
	}

	sc := state.scope
	// try to resolve variables in the current scope
	vl, ok := sc.variables[name]
	// if not found walks parent scopes
	for !ok && sc.parent != nil {
		sc = sc.parent
		vl, ok = sc.variables[name]
	}

	// if not found check globals
	if !ok {
		state.set.gmx.RLock()
		vl, ok = state.set.globals[name]
		state.set.gmx.RUnlock()
		// not found check defaultVariables
		if !ok {
			vl, ok = defaultVariables[name]
		}
	}
	return vl
}
103777
func (c Configuration) Resolve() (string, error) {
	r, err := c.resolver()
	if err != nil {
		return "", err
	}
	return r.ID()
}
998026
func (c Configuration) Resolve() (string, error) {
	listenAddrType := c.ListenAddressType

	var listenAddress string
	switch listenAddrType {
	case ConfigResolver:
		if c.Value == nil {
			err := fmt.Errorf("missing listen address value using: resolver=%s",
				string(listenAddrType))
			return "", err
		}
		listenAddress = *c.Value

	case EnvironmentResolver:
		// environment variable for port is required
		if c.EnvVarListenPort == nil {
			err := fmt.Errorf("missing port env var name using: resolver=%s",
				string(listenAddrType))
			return "", err
		}
		portStr := os.Getenv(*c.EnvVarListenPort)
		port, err := strconv.Atoi(portStr)
		if err != nil {
			err := fmt.Errorf("invalid port env var value using: resolver=%s, name=%s",
				string(listenAddrType), *c.EnvVarListenPort)
			return "", err
		}
		// if environment variable for hostname is not set, use the default
		if c.EnvVarListenHost == nil {
			listenAddress = fmt.Sprintf("%s:%d", defaultHostname, port)
		} else {
			envHost := os.Getenv(*c.EnvVarListenHost)
			listenAddress = fmt.Sprintf("%s:%d", envHost, port)
		}

	default:
		return "", fmt.Errorf("unknown listen address type: resolver=%s",
			string(listenAddrType))
	}

	return listenAddress, nil
}