本文整理汇总了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]))
}
}
}
示例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
}
示例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
}
示例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
}
示例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]))
}
}
}