in commands/util.go [1074:1107]
func ReadProps(path string) (map[string]string, error) {
props := map[string]string{}
file, err := os.Open(path)
if err != nil {
// If file does not exist, just return props
whisk.Debug(whisk.DbgWarn, "Unable to read whisk properties file '%s' (file open error: %s); falling back to default properties\n", path, err)
return props, nil
}
defer file.Close()
lines := []string{}
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
props = map[string]string{}
for _, line := range lines {
re := regexp.MustCompile("#.*")
line = re.ReplaceAllString(line, "")
line = strings.TrimSpace(line)
kv := strings.Split(line, "=")
if len(kv) != 2 {
// Invalid format; skip
continue
}
props[kv[0]] = kv[1]
}
return props, nil
}