code: func updateSettings(c context.Context) error {
  	// Load the settings from luci-config.
  	cs := cfgclient.CurrentServiceConfigSet(c)
  	lucicfg := GetConfigService(c)
  	cfg, err := lucicfg.GetConfig(c, cs, "settings.cfg", false)
  	if err != nil {
  		return errors.Annotate(err, "loading settings.cfg from luci-config").Err()
  	}
  
  	// Do the revision check & swap in a datastore transaction.
  	return datastore.RunInTransaction(c, func(c context.Context) error {
  		oldSettings := Settings{}
  		err := datastore.Get(c, &oldSettings)
  		switch err {
  		case datastore.ErrNoSuchEntity:
  			// This might be the first time this has run, so a warning here is ok.
  			logging.WithError(err).Warningf(c, "no existing service config")
  		case nil:
  			// Continue
  		default:
  			return errors.Annotate(err, "loading existing config").Err()
  		}
  		// Check to see if we need to update
  		if oldSettings.Revision == cfg.Revision {
  			logging.Debugf(c, "revisions matched (%s), no need to update", cfg.Revision)
  			return nil
  		}
  		newSettings := Settings{Revision: cfg.Revision}
  		if err := proto.UnmarshalText(cfg.Content, &newSettings.Settings); err != nil {
  			return errors.Annotate(err, "unmarshalling proto").Err()
  		}
  		ctx := &validation.Context{Context: c}
  		ctx.SetFile("settings.cfg")
  		validateSettings(ctx, &newSettings.Settings)
  		if err := ctx.Finalize(); err != nil {
  			return errors.Annotate(err, "validating settings").Err()
  		}
  		return datastore.Put(c, &newSettings)
  	}, nil)
  }
docs: // updateSettings fetches the service config from luci-config and then stores
  // the new config into the datastore.