func FindFromPath(p string) (context *Env, err error) { p, err = filepath.Abs(p) if err != nil { return } var kmgFilePath string for { kmgFilePath = filepath.Join(p, ".kmg.yml") _, err = os.Stat(kmgFilePath) if err == nil { //found it break } if !os.IsNotExist(err) { return } thisP := filepath.Dir(p) if p == thisP { err = NotFoundError{} return } p = thisP } context = &Env{} err = kmgYaml.ReadFile(kmgFilePath, context) if err != nil { return } context.ProjectPath, err = filepath.Abs(filepath.Dir(kmgFilePath)) if err != nil { return } context.Init() return }
func mustLoadConfigByFilename(filename string) { conf := TestDbConf{} err := kmgYaml.ReadFile(kmgConfig.DefaultEnv().PathInConfig(filename), &conf) if err != nil { panic(err) } SetDefaultDbConfig(conf.Db) }
func init() { Parameter = &kmgConfig.Parameter{} path := filepath.Join(defaultEnv.Env.ConfigPath, "parameters.yml") err := kmgYaml.ReadFile(path, Parameter) if err != nil { panic(fmt.Errorf("can not get Parameters config,do you forget write a config file at %s ? err: %s", path, err)) } }
// @deprecated func DefaultParameter() *Parameter { parameterOnce.Do(func() { parameter = &Parameter{} path := filepath.Join(DefaultEnv().ConfigPath, "Parameters.yml") err := kmgYaml.ReadFile(path, parameter) if err != nil { panic(fmt.Errorf("can not get Parameters config,do you forget write a config file at %s ? err: %s", path, err)) } }) return parameter }
func FindFromPath(p string) (context *Env, err error) { p, err = kmgFile.SearchFileInParentDir(p, ".kmg.yml") if err != nil { return } kmgFilePath := filepath.Join(p, ".kmg.yml") context = &Env{} err = kmgYaml.ReadFile(kmgFilePath, context) if err != nil { return } context.ProjectPath, err = filepath.Abs(filepath.Dir(kmgFilePath)) if err != nil { return } context.Init() return }