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

Function WriteProps

commands/util.go:1107–1131  ·  view source on GitHub ↗
(path string, props map[string]string)

Source from the content-addressed store, hash-verified

1105}
1106
1107func WriteProps(path string, props map[string]string) error {
1108
1109 file, err := os.Create(path)
1110 if err != nil {
1111 whisk.Debug(whisk.DbgError, "os.Create(%s) failed: %s\n", path, err)
1112 errStr := wski18n.T("Whisk properties file write failure: {{.err}}", map[string]interface{}{"err": err})
1113 werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
1114 return werr
1115 }
1116 defer file.Close()
1117
1118 writer := bufio.NewWriter(file)
1119 defer writer.Flush()
1120 for key, value := range props {
1121 line := fmt.Sprintf("%s=%s", strings.ToUpper(key), value)
1122 _, err = fmt.Fprintln(writer, line)
1123 if err != nil {
1124 whisk.Debug(whisk.DbgError, "fmt.Fprintln() write to '%s' failed: %s\n", path, err)
1125 errStr := wski18n.T("Whisk properties file write failure: {{.err}}", map[string]interface{}{"err": err})
1126 werr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
1127 return werr
1128 }
1129 }
1130 return nil
1131}
1132
1133func getSpaceGuid() (string, error) {
1134 // get current props

Callers 1

property.goFile · 0.85

Calls 1

CreateMethod · 0.80

Tested by

no test coverage detected