当前位置: 首页>>代码示例>>Golang>>正文


Golang Config.Set方法代码示例

本文整理汇总了Golang中github.com/akutz/gofig/types.Config.Set方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.Set方法的具体用法?Golang Config.Set怎么用?Golang Config.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/akutz/gofig/types.Config的用法示例。


在下文中一共展示了Config.Set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: BackCompat

// BackCompat ensures keys can be used from old configurations.
func BackCompat(config gofig.Config) {
	ec2Checks := [][]string{
		{ConfigEBSAccessKey, ConfigEC2AccessKey},
		{ConfigEBSSecretKey, ConfigEC2SecretKey},
		{ConfigEBSRegion, ConfigEC2Region},
		{ConfigEBSEndpoint, ConfigEC2Endpoint},
		{ConfigEBSMaxRetries, ConfigEC2MaxRetries},
		{ConfigEBSTag, ConfigEC2Tag},
		{ConfigEBSRexrayTag, ConfigEC2RexrayTag},
		{ConfigEBSKmsKeyID, ConfigEC2KmsKeyID},
	}
	for _, check := range ec2Checks {
		if !config.IsSet(check[0]) && config.IsSet(check[1]) {
			log.Debug(config.Get(check[1]))
			config.Set(check[0], config.Get(check[1]))
		}
	}

	awsChecks := [][]string{
		{ConfigEBSAccessKey, ConfigAWSAccessKey},
		{ConfigEBSSecretKey, ConfigAWSSecretKey},
		{ConfigEBSRegion, ConfigAWSRegion},
		{ConfigEBSEndpoint, ConfigAWSEndpoint},
		{ConfigEBSMaxRetries, ConfigAWSMaxRetries},
		{ConfigEBSTag, ConfigAWSTag},
		{ConfigEBSRexrayTag, ConfigAWSRexrayTag},
		{ConfigEBSKmsKeyID, ConfigAWSKmsKeyID},
	}
	for _, check := range awsChecks {
		if !config.IsSet(check[0]) && config.IsSet(check[1]) {
			log.Debug(config.Get(check[1]))
			config.Set(check[0], config.Get(check[1]))
		}
	}
}
开发者ID:emccode,项目名称:libstorage,代码行数:36,代码来源:ebs_config_compat.go

示例2: setHost

func setHost(
	ctx apitypes.Context,
	config gofig.Config,
	host string) apitypes.Context {
	ctx = ctx.WithValue(context.HostKey, host)
	ctx.WithField("host", host).Debug("set host in context")
	config.Set(apitypes.ConfigHost, host)
	ctx.WithField("host", host).Debug("set host in config")
	return ctx
}
开发者ID:akutz,项目名称:rexray,代码行数:10,代码来源:util.go

示例3: InitializeDefaultModules

// InitializeDefaultModules initializes the default modules.
func InitializeDefaultModules(
	ctx apitypes.Context,
	config gofig.Config) (<-chan error, error) {

	modTypesRwl.RLock()
	defer modTypesRwl.RUnlock()

	var (
		err  error
		mod  *Instance
		errs <-chan error
	)

	// enable path caching for the modules
	config.Set(apitypes.ConfigIgVolOpsPathCacheEnabled, true)

	ctx, config, errs, err = util.ActivateLibStorage(ctx, config)
	if err != nil {
		return nil, err
	}

	modConfigs, err := getConfiguredModules(ctx, config)
	if err != nil {
		return nil, err
	}

	ctx.WithField("len(modConfigs)", len(modConfigs)).Debug(
		"got configured modules")

	for _, mc := range modConfigs {

		ctx.WithField("name", mc.Name).Debug(
			"creating libStorage client for module instance")

		if mc.Client, err = util.NewClient(ctx, mc.Config); err != nil {
			panic(err)
		}

		if mod, err = InitializeModule(ctx, mc); err != nil {
			return nil, err
		}

		modInstances[mod.Name] = mod
	}

	return errs, nil
}
开发者ID:akutz,项目名称:rexray,代码行数:48,代码来源:module.go

示例4: ActivateLibStorage

// ActivateLibStorage activates libStorage and returns a possibly mutated
// context.
func ActivateLibStorage(
	ctx apitypes.Context,
	config gofig.Config) (apitypes.Context, gofig.Config, <-chan error, error) {

	config = config.Scope("rexray")

	// set the `libstorage.service` property to the value of
	// `rexray.storageDrivers` if the former is not defined and the
	// latter is
	if !config.IsSet(apitypes.ConfigService) &&
		config.IsSet("rexray.storageDrivers") {
		if sd := config.GetStringSlice("rexray.storageDrivers"); len(sd) > 0 {
			config.Set(apitypes.ConfigService, sd[0])
		} else if sd := config.GetString("rexray.storageDrivers"); sd != "" {
			config.Set(apitypes.ConfigService, sd)
		}
	}

	if !config.IsSet(apitypes.ConfigIgVolOpsMountPath) {
		config.Set(apitypes.ConfigIgVolOpsMountPath, LibFilePath("volumes"))
	}

	var (
		err  error
		errs <-chan error
	)

	ctx, config, errs, err = activateLibStorage(ctx, config)
	if err != nil {
		return ctx, config, errs, err
	}

	return ctx, config, errs, nil
}
开发者ID:akutz,项目名称:rexray,代码行数:36,代码来源:util.go

示例5: BackCompat

// BackCompat ensures keys can be used from old configurations.
func BackCompat(config gofig.Config) {
	checks := [][]string{
		{ConfigIgVolOpsMountPreempt, ConfigOldIntegrationVolMountPreempt},
		{ConfigIgVolOpsCreateDisable, ConfigOldIntegrationVolCreateDisable},
		{ConfigIgVolOpsRemoveDisable, ConfigOldIntegrationVolRemoveDisable},
		{ConfigIgVolOpsUnmountIgnoreUsed, ConfigOldIntegrationVolUnmountIgnoreUsed},
		{ConfigIgVolOpsPathCacheEnabled, ConfigOldIntegrationVolPathCache},
		{ConfigIgVolOpsCreateDefaultFsType, ConfigOldDockerFsType},
		{ConfigIgVolOpsCreateDefaultType, ConfigOldDockerVolumeType},
		{ConfigIgVolOpsCreateDefaultIOPS, ConfigOldDockerIOPS},
		{ConfigIgVolOpsCreateDefaultSize, ConfigOldDockerSize},
		{ConfigIgVolOpsCreateDefaultAZ, ConfigOldDockerAvailabilityZone},
		{ConfigIgVolOpsMountPath, ConfigOldDockerMountDirPath},
		{ConfigIgVolOpsMountRootPath, ConfigOldDockerLinuxVolumeRootPath},
	}
	for _, check := range checks {
		if !config.IsSet(check[0]) && config.IsSet(check[1]) {
			log.Debug(config.Get(check[1]))
			config.Set(check[0], config.Get(check[1]))
		}
	}
}
开发者ID:emccode,项目名称:libstorage,代码行数:23,代码来源:types_config_compat.go


注:本文中的github.com/akutz/gofig/types.Config.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。