// forceAdd is used to force a lookup of the given deployment object and create
// a watcher. If the deployment does not exist or is terminal an error is
// returned.
2005
func (w *Watcher) forceAdd(dID string) (*deploymentWatcher, error) {
	snap, err := w.state.Snapshot()
	if err != nil {
		return nil, err
	}

	deployment, err := snap.DeploymentByID(nil, dID)
	if err != nil {
		return nil, err
	}

	if deployment == nil {
		return nil, fmt.Errorf("unknown deployment %q", dID)
	}

	return w.addLocked(deployment)
}
1196077
func (c *ReportingClient) RunStepsAdded(ctx context.Context, args RunStepsAddedArgs) error {
	return c.postJSON("runstepsadded", args)
}
1208836
func indexAdd(storer Storer, tx *bolt.Tx, key []byte, data interface{}) error {
	indexes := storer.Indexes()
	for name, index := range indexes {
		err := indexUpdate(storer.Type(), name, index, tx, key, data, false)
		if err != nil {
			return err
		}
	}

	return nil
}
183133
func (f *Registry) RegisterStandard(name string, version int, newFunc interface{}) error {
	wrapped, facadeType, err := wrapNewFacade(newFunc)
	if err != nil {
		return errors.Trace(err)
	}
	err = f.Register(name, version, wrapped, facadeType)
	if err != nil {
		return errors.Trace(err)
	}
	return nil
}
1248668
func (w *deploymentWatcher) createBatchedUpdate(allowReplacements []string, forIndex uint64) {
	w.l.Lock()
	defer w.l.Unlock()

	// Store the allocations that can be replaced
	for _, allocID := range allowReplacements {
		if w.outstandingAllowReplacements == nil {
			w.outstandingAllowReplacements = make(map[string]*structs.DesiredTransition, len(allowReplacements))
		}
		w.outstandingAllowReplacements[allocID] = allowRescheduleTransition
	}

	if w.outstandingBatch || (forIndex < w.latestEval && len(allowReplacements) == 0) {
		return
	}

	w.outstandingBatch = true

	time.AfterFunc(perJobEvalBatchPeriod, func() {
		// If the timer has been created and then we shutdown, we need to no-op
		// the evaluation creation.
		select {
		case <-w.ctx.Done():
			return
		default:
		}

		w.l.Lock()
		replacements := w.outstandingAllowReplacements
		w.outstandingAllowReplacements = nil
		w.outstandingBatch = false
		w.l.Unlock()

		// Create the eval
		if _, err := w.createUpdate(replacements, w.getEval()); err != nil {
			w.logger.Error("failed to create evaluation for deployment", "deployment_id", w.deploymentID, "error", err)
		}
	})
}
715832
func (s *ResourceState) ProviderAddr() (addrs.AbsProviderConfig, error) {
	var diags tfdiags.Diagnostics

	str := s.Provider
	traversal, travDiags := hclsyntax.ParseTraversalAbs([]byte(str), "", hcl.Pos{Line: 1, Column: 1})
	diags = diags.Append(travDiags)
	if travDiags.HasErrors() {
		return addrs.AbsProviderConfig{}, diags.Err()
	}

	addr, addrDiags := addrs.ParseAbsProviderConfig(traversal)
	diags = diags.Append(addrDiags)
	return addr, diags.Err()
}
570560
func (n *mutDir) maybeAddChild(name string, permanode *search.DescribedPermanode,
	child mutFileOrDir) {
	if current, ok := n.children[name]; !ok ||
		current.permanodeString() != child.permanodeString() {

		child.xattr().load(permanode)
		n.children[name] = child
	}
}
342507
func (db *RedisDB) setAdd(k string, elems ...string) int {
	s, ok := db.setKeys[k]
	if !ok {
		s = setKey{}
		db.keys[k] = "set"
	}
	added := 0
	for _, e := range elems {
		if _, ok := s[e]; !ok {
			added++
		}
		s[e] = struct{}{}
	}
	db.setKeys[k] = s
	db.keyVersion[k]++
	return added
}
1032036
func (c FavoriteClient) FavoriteAdd(ctx context.Context, __arg FavoriteAddArg) (err error) {
	err = c.Cli.Call(ctx, "keybase.1.favorite.favoriteAdd", []interface{}{__arg}, nil)
	return
}
536433
func (k *KeybaseServiceBase) FavoriteAdd(ctx context.Context, folder keybase1.Folder) error {
	return k.favoriteClient.FavoriteAdd(ctx, keybase1.FavoriteAddArg{Folder: folder})
}
336803
func (rtm *Client) ReactionsAdd(name string, fileID, fileCommentID, channelID *string, ts *Timestamp) error {
	res := basicResponse{}
	req := NewExternalRequest().
		AsPost().
		WithScheme(APIScheme).
		WithHost(APIEndpoint).
		WithPath("api/reactions.add").
		WithPostData("token", rtm.Token).
		WithPostData("name", name)

	if fileID != nil {
		req = req.WithPostData("file", *fileID)
	} else if fileCommentID != nil {
		req = req.WithPostData("file_comment", *fileCommentID)
	} else if channelID != nil && ts != nil {
		req = req.WithPostData("channel", *channelID)
		req = req.WithPostData("timestamp", ts.String())
	} else {
		return exception.New("`fileId` or `fileCommentID` or (`channelID` and `ts`) must be not be nil.")
	}

	err := req.JSON(&res)

	if err != nil {
		return err
	}

	if !IsEmpty(res.Error) {
		return exception.New(res.Error)
	}

	if !res.OK {
		return exception.New("slack response `ok` is false.")
	}
	return nil
}
704856
func (db *DB) ForceUse(name string) *Col {
	db.schemaLock.RLock()
	defer db.schemaLock.RUnlock()
	if db.cols[name] == nil {
		if err := db.create(name); err != nil {
			tdlog.Panicf("ForceUse: failed to create collection - %v", err)
		}
	}
	return db.cols[name]
}
1283133
func MakeAddReferenceArg(tlfID tlf.ID, id ID, context Context) keybase1.AddReferenceArg {
	return keybase1.AddReferenceArg{
		Ref:    makeReference(id, context),
		Folder: tlfID.String(),
	}
}
1181186
func DomainsAdd(appID, domain string) error {
	c, appID, err := load(appID)

	if err != nil {
		return err
	}

	fmt.Printf("Adding %s to %s... ", domain, appID)

	quit := progress()
	_, err = domains.New(c, appID, domain)
	quit <- true
	<-quit

	if err != nil {
		return err
	}

	fmt.Println("done")
	return nil
}
607662
func (d *delegationCommander) delegationAdd(cmd *cobra.Command, args []string) error {
	// We must have at least the gun and role name, and at least one key or path (or the --all-paths flag) to add
	if len(args) < 2 || len(args) < 3 && d.paths == nil && !d.allPaths {
		cmd.Usage()
		return fmt.Errorf("must specify the Global Unique Name and the role of the delegation along with the public key certificate paths and/or a list of paths to add")
	}

	config, err := d.configGetter()
	if err != nil {
		return err
	}

	gun := data.GUN(args[0])
	role := data.RoleName(args[1])

	pubKeys, err := ingestPublicKeys(args)
	if err != nil {
		return err
	}

	checkAllPaths(d)

	trustPin, err := getTrustPinning(config)
	if err != nil {
		return err
	}

	// no online operations are performed by add so the transport argument
	// should be nil
	nRepo, err := notaryclient.NewFileCachedRepository(
		config.GetString("trust_dir"), gun, getRemoteTrustServer(config), nil, d.retriever, trustPin)
	if err != nil {
		return err
	}

	// Add the delegation to the repository
	err = nRepo.AddDelegation(role, pubKeys, d.paths)
	if err != nil {
		return fmt.Errorf("failed to create delegation: %v", err)
	}

	// Make keyID slice for better CLI print
	pubKeyIDs := []string{}
	for _, pubKey := range pubKeys {
		pubKeyID, err := utils.CanonicalKeyID(pubKey)
		if err != nil {
			return err
		}
		pubKeyIDs = append(pubKeyIDs, pubKeyID)
	}

	cmd.Println("")
	addingItems := ""
	if len(pubKeyIDs) > 0 {
		addingItems = addingItems + fmt.Sprintf("with keys %s, ", pubKeyIDs)
	}
	if d.paths != nil || d.allPaths {
		addingItems = addingItems + fmt.Sprintf(
			"with paths [%s], ",
			strings.Join(prettyPaths(d.paths), "\n"),
		)
	}
	cmd.Printf(
		"Addition of delegation role %s %sto repository \"%s\" staged for next publish.\n",
		role, addingItems, gun)
	cmd.Println("")

	return maybeAutoPublish(cmd, d.autoPublish, gun, config, d.retriever)
}
994528
func SafeAdd(x, y uint64) (uint64, bool) {
	return x + y, y > MaxUint64-x
}
835033
func (c *Client) LinkAdd(bucket, key, lbucket, lkey, ltag string) error {
	obj, err := c.FetchObject(bucket, key)
	if err != nil {
		return err
	}

	if len(obj.GetContent()) == 0 {
		return ErrNoContent
	}

	link := &RpbLink{
		Bucket: []byte(lbucket),
		Key:    []byte(lkey),
		Tag:    []byte(ltag),
	}
	obj.Content[0].Links = append(obj.Content[0].Links, link)

	if _, err := c.StoreObject(bucket, key, obj.GetContent()[0]); err != nil {
		return err
	}

	return nil
}