MCPcopy Create free account
hub / github.com/apache/openwhisk-cli / ReadProps

Function ReadProps

commands/util.go:1072–1105  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

1070}
1071
1072func ReadProps(path string) (map[string]string, error) {
1073
1074 props := map[string]string{}
1075
1076 file, err := os.Open(path)
1077 if err != nil {
1078 // If file does not exist, just return props
1079 whisk.Debug(whisk.DbgWarn, "Unable to read whisk properties file '%s' (file open error: %s); falling back to default properties\n", path, err)
1080 return props, nil
1081 }
1082 defer file.Close()
1083
1084 lines := []string{}
1085 scanner := bufio.NewScanner(file)
1086 for scanner.Scan() {
1087 lines = append(lines, scanner.Text())
1088 }
1089
1090 props = map[string]string{}
1091 for _, line := range lines {
1092 re := regexp.MustCompile("#.*")
1093 line = re.ReplaceAllString(line, "")
1094 line = strings.TrimSpace(line)
1095 kv := strings.Split(line, "=")
1096 if len(kv) != 2 {
1097 // Invalid format; skip
1098 continue
1099 }
1100 props[kv[0]] = kv[1]
1101 }
1102
1103 return props, nil
1104
1105}
1106
1107func WriteProps(path string, props map[string]string) error {
1108

Callers 5

getAccessTokenFunction · 0.85
getUserContextIdFunction · 0.85
property.goFile · 0.85
loadPropertiesFunction · 0.85
getSpaceGuidFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected