func GetServerConfig(conf *vault.Config) (interface{}, error) { typ := "" t := conf.Server["Type"] if t == nil { t = conf.Server["type"] } if t != nil { typ = t.(string) } var sConf interface{} if strings.ToLower(typ) == "tcp" { var config VaultServerTCPConfig err := mapstructure.Decode(conf.Server, &config) if err != nil { return nil, err } sConf = config } else if strings.ToLower(typ) == "unix" { var config VaultServerUnixConfig mapstructure.Decode(conf.Server, &config) sConf = config } return sConf, nil }
func loadServer(v *vault.Vault, conf *vault.Config) (*server.VaultServer, error) { typ := "" t := conf.Server["Type"] if t == nil { t = conf.Server["type"] } if t != nil { typ = t.(string) } var sConf interface{} if strings.ToLower(typ) == "tcp" { var config server.VaultServerTCPConfig err := mapstructure.Decode(conf.Server, &config) if err != nil { return nil, err } sConf = config } else if strings.ToLower(typ) == "unix" { var config server.VaultServerUnixConfig mapstructure.Decode(conf.Server, &config) sConf = config } return server.NewVaultServer(v, sConf) }
func (f *Form) GetValue(v interface{}) error { if f.Value == nil { return errors.New("no value") } return mapstructure.Decode(f.Value, v) }