Merge branch 'master' into feature-config-golang

This commit is contained in:
Jose Diaz-Gonzalez
2017-10-04 19:04:31 -04:00
committed by GitHub
143 changed files with 4954 additions and 302 deletions

View File

@@ -17,6 +17,28 @@ func GetWithDefault(appName string, key string, defaultValue string) string {
return env.GetDefault(key, defaultValue)
}
// GetWithDefault returns the value set for a given key, returning defaultValue if none found
// func GetWithDefault(appName string, key string, defaultValue string) (value string) {
// value = defaultValue
// envFile := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName, "ENV"}, "/")
// lines, err := common.FileToSlice(envFile)
// if err != nil {
// return
// }
// prefix := fmt.Sprintf("export %v=", key)
// for _, line := range lines {
// if !strings.HasPrefix(line, prefix) {
// continue
// }
// value = strings.TrimPrefix(line, prefix)
// if strings.HasPrefix(value, "'") && strings.HasSuffix(value, "'") {
// value = strings.TrimPrefix(strings.TrimSuffix(value, "'"), "'")
// }
// }
// return
// }
//HasKey determines if the config given by appName has a value for the given key
func HasKey(appName string, key string) bool {
env, err := loadConfig(appName)