// RequireKeyUnchanged returns a precondition function that fails if the provided key
// is present in the patch (indicating that its value has changed).
774111
func RequireKeyUnchanged(key string) PreconditionFunc {
	return func(patch interface{}) bool {
		patchMap, ok := patch.(map[string]interface{})
		if !ok {
			return true
		}

		// The presence of key means that its value has been changed, so the test fails.
		_, ok = patchMap[key]
		return !ok
	}
}
881799
func (c *Config) GetRequired(key string) Value {
	val, err := c.Get(key)
	if err != nil {
		configErrorf("Configuration parameter %s is mandatory", key)
	}
	return val
}
1185040
func (state *ServicesState) ServiceChanged(svc *service.Service, previousStatus int, updated time.Time) {
	state.serverChanged(svc.Hostname, updated)
	state.NotifyListeners(svc, previousStatus, state.LastChanged)
}
217844
func (f File) HasVendoredCodeChanges() bool {
	return strings.HasPrefix(string(f), "Godeps/_workspace") ||
		strings.HasPrefix(string(f), "vendor") ||
		strings.HasPrefix(string(f), "pkg/build/vendor")
}
1122503
func (s *Version) SetRequiredCapabilities(v []*string) *Version {
	s.RequiredCapabilities = v
	return s
}
1151920
func (s *ActionConfigurationProperty) SetRequired(v bool) *ActionConfigurationProperty {
	s.Required = &v
	return s
}
721681
func (*DatacentersTable) needsUpdate(row, cfg *Datacenter) bool {
	return row.Description != cfg.Description || row.State != cfg.State
}
162997
func MustNewFrom(from interface{}, opts ...Option) *Config {
	c := New()
	if err := c.Merge(from, opts...); err != nil {
		panic(err)
	}
	return c
}
1044106
func volumesChanged(ctx *context, changes []string) error {
	tags := make([]names.Tag, len(changes))
	for i, change := range changes {
		tags[i] = names.NewVolumeTag(change)
	}
	alive, dying, dead, err := storageEntityLife(ctx, tags)
	if err != nil {
		return errors.Trace(err)
	}
	logger.Debugf("volumes alive: %v, dying: %v, dead: %v", alive, dying, dead)
	if err := processDyingVolumes(ctx, dying); err != nil {
		return errors.Annotate(err, "processing dying volumes")
	}
	if len(alive)+len(dead) == 0 {
		return nil
	}

	// Get volume information for alive and dead volumes, so
	// we can provision/deprovision.
	volumeTags := make([]names.VolumeTag, 0, len(alive)+len(dead))
	for _, tag := range alive {
		volumeTags = append(volumeTags, tag.(names.VolumeTag))
	}
	for _, tag := range dead {
		volumeTags = append(volumeTags, tag.(names.VolumeTag))
	}
	volumeResults, err := ctx.config.Volumes.Volumes(volumeTags)
	if err != nil {
		return errors.Annotatef(err, "getting volume information")
	}
	if err := processDeadVolumes(ctx, volumeTags[len(alive):], volumeResults[len(alive):]); err != nil {
		return errors.Annotate(err, "deprovisioning volumes")
	}
	if err := processAliveVolumes(ctx, alive, volumeResults[:len(alive)]); err != nil {
		return errors.Annotate(err, "provisioning volumes")
	}
	return nil
}
745769
func (s *Settings) ClearOnChange(key string) {
	s.lock.Lock()
	defer s.lock.Unlock()
	delete(s.onChangeCallbacks, key)
}
1151433
func (k *KeybaseServiceBase) ReachabilityChanged(ctx context.Context,
	reachability keybase1.Reachability) error {
	k.log.CDebugf(ctx, "CheckReachability invoked: %v", reachability)
	if reachability.Reachable == keybase1.Reachable_YES {
		k.config.KBFSOps().PushConnectionStatusChange(GregorServiceName, nil)
	} else {
		k.config.KBFSOps().PushConnectionStatusChange(
			GregorServiceName, errDisconnected{})
	}
	mdServer := k.config.MDServer()
	if mdServer != nil {
		mdServer.CheckReachability(ctx)
	}
	return nil
}
1373464
func (s *UpdateLoginProfileInput) SetPasswordResetRequired(v bool) *UpdateLoginProfileInput {
	s.PasswordResetRequired = &v
	return s
}
70508
func (k *keyCommander) keyPassphraseChange(cmd *cobra.Command, args []string) error {
	if len(args) < 1 {
		cmd.Usage()
		return fmt.Errorf("must specify the key ID of the key to change the passphrase of")
	}

	config, err := k.configGetter()
	if err != nil {
		return err
	}
	ks, err := k.getKeyStores(config, true, false)
	if err != nil {
		return err
	}

	keyID := args[0]

	// This is an invalid ID
	if len(keyID) != notary.SHA256HexSize {
		return fmt.Errorf("invalid key ID provided: %s", keyID)
	}

	// Find which keyStore we should replace the key password in, and replace if we find it
	var foundKeyStore trustmanager.KeyStore
	var privKey data.PrivateKey
	var keyInfo trustmanager.KeyInfo
	var cs *cryptoservice.CryptoService
	for _, keyStore := range ks {
		cs = cryptoservice.NewCryptoService(keyStore)
		if privKey, _, err = cs.GetPrivateKey(keyID); err == nil {
			foundKeyStore = keyStore
			break
		}
	}
	if foundKeyStore == nil {
		return fmt.Errorf("could not retrieve local key for key ID provided: %s", keyID)
	}
	// Must use a different passphrase retriever to avoid caching the
	// unlocking passphrase and reusing that.
	passChangeRetriever := k.getRetriever()
	var addingKeyStore trustmanager.KeyStore
	switch foundKeyStore.Name() {
	case "yubikey":
		addingKeyStore, err = getYubiStore(nil, passChangeRetriever)
		keyInfo = trustmanager.KeyInfo{Role: data.CanonicalRootRole}
	default:
		addingKeyStore, err = trustmanager.NewKeyFileStore(config.GetString("trust_dir"), passChangeRetriever)
		if err != nil {
			return err
		}
		keyInfo, err = foundKeyStore.GetKeyInfo(keyID)
	}
	if err != nil {
		return err
	}
	err = addingKeyStore.AddKey(keyInfo, privKey)
	if err != nil {
		return err
	}
	cmd.Printf("\nSuccessfully updated passphrase for key ID: %s\n", keyID)
	return nil
}
273743
func (k *KeybaseDaemonRPC) FavoritesChanged(ctx context.Context,
	uid keybase1.UID) error {
	k.log.Debug("Received FavoritesChanged RPC.")
	k.config.KBFSOps().RefreshCachedFavorites(ctx)
	return nil
}
1373446
func ValidateRequired(ch *Changeset, fields []string, opts ...Option) {
	options := Options{
		message: ValidateRequiredErrorMessage,
	}
	options.apply(opts)

	for _, f := range fields {
		val, exist := ch.changes[f]

		// check values if it's not exist in changeset when changeOnly is false and changeset values are all zero value
		if !exist && !options.changeOnly && !ch.zero {
			val, exist = ch.values[f]
		}

		str, isStr := val.(string)
		if exist && (isStr && strings.TrimSpace(str) != "") || (!isStr && val != nil) {
			continue
		}

		msg := strings.Replace(options.message, "{field}", f, 1)
		AddError(ch, f, msg)
	}
}
374320
func (c *Conn) EnableFKConstraints(e bool) error {
	q := fkChecksEnabled
	if !e {
		q = fkChecksDisabled
	}
	_, err := c.sqlite.Exec(q, nil)
	return err
}
116468
func invokeCheckChanges(a, e, changes Task) error {
	rv, err := reflectutils.InvokeMethod(e, "CheckChanges", a, e, changes)
	if err != nil {
		return err
	}
	if !rv[0].IsNil() {
		err = rv[0].Interface().(error)
	}
	return err
}