本文整理汇总了Golang中github.com/akutz/gofig/types.Config.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.Get方法的具体用法?Golang Config.Get怎么用?Golang Config.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/akutz/gofig/types.Config
的用法示例。
在下文中一共展示了Config.Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: printConfig
func printConfig(title string, c types.Config, t *testing.T) {
for _, k := range c.AllKeys() {
if title == "" {
t.Logf("%s=%v", k, c.Get(k))
} else {
t.Logf("%s - %s=%v", title, k, c.Get(k))
}
}
}
示例2: assertConfigsEqual
func assertConfigsEqual(c1 types.Config, c2 types.Config, t *testing.T) bool {
printConfig("c1", c1, t)
t.Log("")
printConfig("c2", c2, t)
t.Log("")
c1Keys := c1.AllKeys()
c2Keys := c2.AllKeys()
for _, k := range c1Keys {
c1v := c1.Get(k)
c2v := c2.Get(k)
if !reflect.DeepEqual(c1v, c2v) {
t.Logf("%s != in both configs; "+
"c1v:type=%[2]T,val=%[2]v; "+
"c2v:type=%[3]T,val=%[3]v", k, c1v, c2v)
return false
}
}
for _, k := range c2Keys {
c1v := c1.Get(k)
c2v := c2.Get(k)
if !reflect.DeepEqual(c1v, c2v) {
t.Logf("%s != in both configs; "+
"c1v:type=%[2]T,val=%[2]v; "+
"c2v:type=%[3]T,val=%[3]v", k, c1v, c2v)
return false
}
}
return true
}
示例3: 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]))
}
}
}
示例4: getConfiguredModules
func getConfiguredModules(
ctx apitypes.Context, c gofig.Config) ([]*Config, error) {
mods := c.Get("rexray.modules")
modMap, ok := mods.(map[string]interface{})
if !ok {
return nil, goof.New("invalid format rexray.modules")
}
ctx.WithField("count", len(modMap)).Debug("got modules map")
modConfigs := []*Config{}
for name := range modMap {
name = strings.ToLower(name)
ctx.WithField("name", name).Debug("processing module config")
sc := c.Scope(fmt.Sprintf("rexray.modules.%s", name))
if disabled := sc.GetBool("disabled"); disabled {
ctx.WithField("name", name).Debug("ignoring disabled module config")
continue
}
mc := &Config{
Name: name,
Type: strings.ToLower(sc.GetString("type")),
Description: sc.GetString("desc"),
Address: sc.GetString("host"),
Config: sc,
}
ctx.WithFields(log.Fields{
"name": mc.Name,
"type": mc.Type,
"desc": mc.Description,
"addr": mc.Address,
}).Info("created new mod config")
modConfigs = append(modConfigs, mc)
}
return modConfigs, 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]))
}
}
}