Пример #1
0
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
}
Пример #2
0
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)

}
Пример #3
0
func (f *Form) GetValue(v interface{}) error {
	if f.Value == nil {
		return errors.New("no value")
	}
	return mapstructure.Decode(f.Value, v)
}