// ModifyConfig makes a context with a derived configuration.
//
// It grabs current configuration from the context (if any), passes it to the
// callback, and puts whatever callback returns into a derived context.
485557
func ModifyConfig(c context.Context, cb func(Config) Config) context.Context {
	var cfg Config
	if cur := getConfig(c); cur != nil {
		cfg = *cur
	}
	cfg = cb(cfg)
	return setConfig(c, &cfg)
}
335118
func (m *MockAgent) ChangeConfig(arg0 agent.ConfigMutator) error {
	ret := m.ctrl.Call(m, "ChangeConfig", arg0)
	ret0, _ := ret[0].(error)
	return ret0
}
1063634
func (c ConfigMap) Config(name string) (string, bool) {
	val, ok := c[name]
	return val, ok
}
955225
func (c *Configs) setConfig(confName configName, value *ConfigSettings) {
	assert(len(confName) == len(c.ConfigVariables))
	assert(value != nil)
	key := confName.key()
	pair, ok := c.byConfig[key]
	assert(!ok, "setConfig must not override existing keys (%s => %v)", key, pair.value)
	c.byConfig[key] = configPair{confName, value}
}
513648
func (c *configCommand) setConfig(client applicationAPI, ctx *cmd.Context) error {
	if c.useFile {
		return c.setConfigFromFile(client, ctx)
	}

	settings, err := c.validateValues(ctx)
	if err != nil {
		return errors.Trace(err)
	}

	result, err := client.Get(c.branchName, c.applicationName)
	if err != nil {
		return err
	}

	for k, v := range settings {
		configValue := result.CharmConfig[k]

		configValueMap, ok := configValue.(map[string]interface{})
		if ok {
			// convert the value to string and compare
			if fmt.Sprintf("%v", configValueMap["value"]) == v {
				logger.Warningf("the configuration setting %q already has the value %q", k, v)
			}
		}
	}

	if client.BestAPIVersion() < 6 {
		err = client.Set(c.applicationName, settings)
	} else {
		err = client.SetApplicationConfig(c.branchName, c.applicationName, settings)
	}
	return block.ProcessBlockedError(err, block.BlockChange)
}
655423
func modifyHostConfig(sc *runtimeapi.LinuxContainerSecurityContext, hostConfig *dockercontainer.HostConfig, separator rune) error {
	if sc == nil {
		return nil
	}

	// Apply supplemental groups.
	for _, group := range sc.SupplementalGroups {
		hostConfig.GroupAdd = append(hostConfig.GroupAdd, strconv.FormatInt(group, 10))
	}

	// Apply security context for the container.
	hostConfig.Privileged = sc.Privileged
	hostConfig.ReadonlyRootfs = sc.ReadonlyRootfs
	if sc.Capabilities != nil {
		hostConfig.CapAdd = sc.GetCapabilities().AddCapabilities
		hostConfig.CapDrop = sc.GetCapabilities().DropCapabilities
	}
	if sc.SelinuxOptions != nil {
		hostConfig.SecurityOpt = addSELinuxOptions(
			hostConfig.SecurityOpt,
			sc.SelinuxOptions,
			separator,
		)
	}

	// Apply apparmor options.
	apparmorSecurityOpts, err := getApparmorSecurityOpts(sc, separator)
	if err != nil {
		return fmt.Errorf("failed to generate apparmor security options: %v", err)
	}
	hostConfig.SecurityOpt = append(hostConfig.SecurityOpt, apparmorSecurityOpts...)

	if sc.NoNewPrivs {
		hostConfig.SecurityOpt = append(hostConfig.SecurityOpt, "no-new-privileges")
	}

	if !hostConfig.Privileged {
		hostConfig.MaskedPaths = sc.MaskedPaths
		hostConfig.ReadonlyPaths = sc.ReadonlyPaths
	}

	return nil
}
1311262
func (network *HostComputeNetwork) ModifyNetworkSettings(request *ModifyNetworkSettingRequest) error {
	logrus.Debugf("hcn::HostComputeNetwork::ModifyNetworkSettings id=%s", network.Id)

	networkSettingsRequest, err := json.Marshal(request)
	if err != nil {
		return err
	}

	_, err = modifyNetwork(network.Id, string(networkSettingsRequest))
	if err != nil {
		return err
	}
	return nil
}
946606
func modifyContainerConfig(sc *runtimeapi.LinuxContainerSecurityContext, config *dockercontainer.Config) error {
	if sc == nil {
		return nil
	}
	if sc.RunAsUser != nil {
		config.User = strconv.FormatInt(sc.GetRunAsUser().Value, 10)
	}
	if sc.RunAsUsername != "" {
		config.User = sc.RunAsUsername
	}

	user := config.User
	if sc.RunAsGroup != nil {
		if user == "" {
			return fmt.Errorf("runAsGroup is specified without a runAsUser.")
		}
		user = fmt.Sprintf("%s:%d", config.User, sc.GetRunAsGroup().Value)
	}

	config.User = user

	return nil
}
215751
func DefaultConfig() Config {
	return Config{
		AllowMethods:     []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"},
		AllowHeaders:     []string{"Origin", "Content-Length", "Content-Type"},
		AllowCredentials: false,
		MaxAge:           12 * time.Hour,
	}
}
890627
func (c *Config) Config() *Config {
	// Guard against nil pointer dereference
	if c == nil {
		return NewConfig()
	}

	// Return a clone of the config so that this is immutable for the receiver
	c2 := *c
	return &c2
}
329634
func (ctx *AssertContext) AddConfig(config *config.GCSCli) {
	ctx.Config = config
	for _, opt := range ctx.options {
		opt(ctx)
	}
	ctx.ConfigPath = MakeConfigFile(ctx.Config)
}
152238
func (conf *PluginConfig) Override(key string, value interface{}) {
	key = conf.registerKey(key)
	conf.Settings[key] = value
}
643678
func (s *ConfigurationService) UpdateConfiguration(p *UpdateConfigurationParams) (*UpdateConfigurationResponse, error) {
	resp, err := s.cs.newRequest("updateConfiguration", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r UpdateConfigurationResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
471110
func (b *Broker) AlterConfigs(request *AlterConfigsRequest) (*AlterConfigsResponse, error) {
	response := new(AlterConfigsResponse)

	err := b.sendAndReceive(request, response)
	if err != nil {
		return nil, err
	}

	return response, nil
}
513529
func withConfig(c context.Context, cfg config.ConfigurationServer) context.Context {
	return context.WithValue(c, &cfgKey, cfg)
}
771675
func (s *Step) SetConfig(v *HadoopStepConfig) *Step {
	s.Config = v
	return s
}
1126001
func (m *MockGeneration) Config() map[string]settings.ItemChanges {
	ret := m.ctrl.Call(m, "Config")
	ret0, _ := ret[0].(map[string]settings.ItemChanges)
	return ret0
}