// UpdateSetting updates a setting at the given key.
192639
func (m *MemoryStorage) UpdateSetting(c context.Context, key string, value json.RawMessage, who, why string) error {
	m.lock.Lock()
	defer m.lock.Unlock()
	if m.values == nil {
		m.values = make(map[string]*json.RawMessage, 1)
	}
	cpy := append(json.RawMessage(nil), value...)
	m.values[key] = &cpy
	return nil
}
1370462
func NewSettingsManager(ctx context.Context, clientset kubernetes.Interface, namespace string) *SettingsManager {

	mgr := &SettingsManager{
		ctx:       ctx,
		clientset: clientset,
		namespace: namespace,
		mutex:     &sync.Mutex{},
	}

	return mgr
}
51134
func (a *Application) UpdateCharmConfig(branchName string, changes charm.Settings) error {
	ch, _, err := a.Charm()
	if err != nil {
		return errors.Trace(err)
	}
	changes, err = ch.Config().ValidateSettings(changes)
	if err != nil {
		return errors.Trace(err)
	}

	// TODO(fwereade) state.Settings is itself really problematic in just
	// about every use case. This needs to be resolved some time; but at
	// least the settings docs are keyed by charm url as well as application
	// name, so the actual impact of a race is non-threatening.
	current, err := readSettings(a.st.db(), settingsC, a.charmConfigKey())
	if err != nil {
		return errors.Annotatef(err, "charm config for application %q", a.doc.Name)
	}

	if branchName == model.GenerationMaster {
		return errors.Trace(a.updateMasterConfig(current, changes))
	}
	return errors.Trace(a.updateBranchConfig(branchName, current, changes))
}
41144
func settingsUpdater(c context.Context) {
	for {
		set := coordinator.GetSettings(c)
		logging.Debugf(c, "updating settings: %v", set)
		if batchSize != set.ArchivistBatchSize {
			batchSize = set.ArchivistBatchSize
		}
		if leaseTime != set.ArchivistLeaseTime {
			leaseTime = set.ArchivistLeaseTime
		}
		clock.Sleep(c, 5*time.Minute)
	}
}
140360
func (p *WebPage) SetSettings(settings WebPageSettings) error {
	req := map[string]interface{}{
		"ref": p.ref.id,
		"settings": webPageSettingsJSON{
			JavascriptEnabled:             settings.JavascriptEnabled,
			LoadImages:                    settings.LoadImages,
			LocalToRemoteURLAccessEnabled: settings.LocalToRemoteURLAccessEnabled,
			UserAgent:                     settings.UserAgent,
			Username:                      settings.Username,
			Password:                      settings.Password,
			XSSAuditingEnabled:            settings.XSSAuditingEnabled,
			WebSecurityEnabled:            settings.WebSecurityEnabled,
			ResourceTimeout:               int(settings.ResourceTimeout / time.Millisecond),
		},
	}
	return p.ref.process.doJSON("POST", "/webpage/SetSettings", req, nil)
}
1206808
func (s *UpdateJobTemplateInput) SetSettings(v *JobTemplateSettings) *UpdateJobTemplateInput {
	s.Settings = v
	return s
}
1354670
func (s *DescribeStreamProcessorOutput) SetSettings(v *StreamProcessorSettings) *DescribeStreamProcessorOutput {
	s.Settings = v
	return s
}
58675
func (s *UpdateConferenceProviderInput) SetMeetingSetting(v *MeetingSetting) *UpdateConferenceProviderInput {
	s.MeetingSetting = v
	return s
}
143872
func (c *Conn) UpdateSetting(args map[string]interface{}, filter_indices ...string) (ClusterStateResponse, error) {
	var url string
	var retval ClusterStateResponse

	url = "/_cluster/state"

	body, err := c.DoCommand("GET", url, args, nil)
	if err != nil {
		return retval, err
	}
	if err == nil {
		// marshall into json
		jsonErr := json.Unmarshal(body, &retval)
		if jsonErr != nil {
			return retval, jsonErr
		}
	}
	return retval, err
}
642071
func (s *StateSettings) ReadSettings(key string) (map[string]interface{}, error) {
	if s, err := readSettings(s.backend.db(), s.collection, key); err != nil {
		return nil, err
	} else {
		return s.Map(), nil
	}
}
1010269
func removeSettings(db Database, collection, key string) error {
	err := db.RunTransaction([]txn.Op{removeSettingsOp(collection, key)})
	if err == txn.ErrAborted {
		return errors.NotFoundf("settings")
	} else if err != nil {
		return errors.Trace(err)
	}
	return nil
}
251227
func (api *MobileGatewayAPI) UpdateSetting(id int64, value *sacloud.MobileGateway) (*sacloud.MobileGateway, error) {
	req := &sacloud.MobileGateway{
		// Settings
		Settings: value.Settings,
	}
	return api.request(func(res *mobileGatewayResponse) error {
		return api.update(id, api.createRequest(req), res)
	})
}
63633
func (a *Application) UpdateLeaderSettings(token leadership.Token, updates map[string]string) error {
	// There's no compelling reason to have these methods on Application -- and
	// thus require an extra db read to access them -- but it stops the State
	// type getting even more cluttered.

	// We can calculate the actual update ahead of time; it's not dependent
	// upon the current state of the document. (*Writing* it should depend
	// on document state, but that's handled below.)
	key := leadershipSettingsKey(a.doc.Name)
	sets := bson.M{}
	unsets := bson.M{}
	for unescapedKey, value := range updates {
		key := mgoutils.EscapeKey(unescapedKey)
		if value == "" {
			unsets[key] = 1
		} else {
			sets[key] = value
		}
	}
	update := setUnsetUpdateSettings(sets, unsets)

	isNullChange := func(rawMap map[string]interface{}) bool {
		for key := range unsets {
			if _, found := rawMap[key]; found {
				return false
			}
		}
		for key, value := range sets {
			if current := rawMap[key]; current != value {
				return false
			}
		}
		return true
	}

	buildTxn := func(_ int) ([]txn.Op, error) {
		// Read the current document state so we can abort if there's
		// no actual change; and the version number so we can assert
		// on it and prevent these settings from landing late.
		doc, err := readSettingsDoc(a.st.db(), settingsC, key)
		if errors.IsNotFound(err) {
			return nil, errors.NotFoundf("application %q", a.doc.Name)
		} else if err != nil {
			return nil, errors.Annotatef(err, "application %q", a.doc.Name)
		}
		if isNullChange(doc.Settings) {
			return nil, jujutxn.ErrNoOperations
		}
		return []txn.Op{{
			C:      settingsC,
			Id:     key,
			Assert: bson.D{{"version", doc.Version}},
			Update: update,
		}}, nil
	}
	return a.st.db().Run(buildTxnWithLeadership(buildTxn, token))
}
473888
func (c ItemChanges) CurrentSettings(defaults charm.Settings) map[string]interface{} {
	result := make(map[string]interface{})
	for _, change := range c {
		key := change.Key

		switch {
		case change.IsModification() && reflect.DeepEqual(change.OldValue, change.NewValue):
			// These are placeholders that we do not apply.
			// See comment in ApplyDeltaSource, above.
		case change.IsDeletion():
			result[key] = defaults[key]
		default:
			result[key] = change.NewValue
		}
	}
	return result
}
62834
func (s *ServiceSetting) SetSettingValue(v string) *ServiceSetting {
	s.SettingValue = &v
	return s
}
869326
func (api *VPCRouterAPI) UpdateSetting(id int64, value *sacloud.VPCRouter) (*sacloud.VPCRouter, error) {
	req := &sacloud.VPCRouter{
		// Settings
		Settings: value.Settings,
	}
	return api.request(func(res *vpcRouterResponse) error {
		return api.update(id, api.createRequest(req), res)
	})
}
1114505
func (s *UpdateWorkGroupInput) SetConfigurationUpdates(v *WorkGroupConfigurationUpdates) *UpdateWorkGroupInput {
	s.ConfigurationUpdates = v
	return s
}