// LoadFile attempts to load the db configuration file stored at the path
// and returns the configuration. On error, it returns nil.
LoadFile attempts to load the db configuration file stored at the path
and returns the configuration. On error, it returns nil.
// LoadFile attempts to load the db configuration file stored at the path // and returns the configuration . On error it returns nil .
func LoadFile(path string) (cfg *DBConfig, err error) {
	log.Debugf("loading db configuration file from %s", path)
	if path == "" {
		return nil, cferr.Wrap(cferr.PolicyError, cferr.InvalidPolicy, errors.New("invalid path"))
	}
	var body []byte
	body, err = ioutil.ReadFile(path)
	if err != nil {
		return nil, cferr.Wrap(cferr.PolicyError, cferr.InvalidPolicy, errors.New("could not read configuration file"))
	}
	cfg = &DBConfig{}
	err = json.Unmarshal(body, &cfg)
	if err != nil {
		return nil, cferr.Wrap(cferr.PolicyError, cferr.InvalidPolicy,
			errors.New("failed to unmarshal configuration: "+err.Error()))
	}
	if cfg.DataSourceName == "" || cfg.DriverName == "" {
		return nil, cferr.Wrap(cferr.PolicyError, cferr.InvalidPolicy, errors.New("invalid db configuration"))
	}
	return
}
func LoadFile ( path string ) ( cfg * DBConfig , err error ) { log . Debugf ( " " , path ) if path == " " { return nil , cferr . Wrap ( cferr . PolicyError , cferr . InvalidPolicy , errors . New ( " " ) ) } var body [ ] byte body , err = ioutil . ReadFile ( path ) if err != nil { return nil , cferr . Wrap ( cferr . PolicyError , cferr . InvalidPolicy , errors . New ( " " ) ) } cfg = & DBConfig { } err = json . Unmarshal ( body , & cfg ) if err != nil { return nil , cferr . Wrap ( cferr . PolicyError , cferr . InvalidPolicy , errors . New ( " " + err . Error ( ) ) ) } if cfg . DataSourceName == " " || cfg . DriverName == " " { return nil , cferr . Wrap ( cferr . PolicyError , cferr . InvalidPolicy , errors . New ( " " ) ) } return }
LoadFile attempts to load the db configuration file stored at the path
and returns the configuration.
LoadFile attempts to load the db configuration file stored at the path and returns the configuration .