mdeuser commented on a change in pull request #2544: Allow CLI to Save Code 
from Action (Review)
URL: 
https://github.com/apache/incubator-openwhisk/pull/2544#discussion_r135876203
 
 

 ##########
 File path: tools/cli/go-whisk-cli/commands/util.go
 ##########
 @@ -866,6 +873,44 @@ func readFile(filename string) (string, error) {
     return string(file), nil
 }
 
+func writeFile(filename string, content string) (error) {
+    file, err := os.Create(filename)
+
+    if err != nil {
+        whisk.Debug(whisk.DbgError, "os.Create(%s) error: %s\n", filename, err)
+        errMsg := wski18n.T("Cannot create file '{{.name}}': {{.err}}",
+            map[string]interface{}{"name": filename, "err": err})
+        whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, 
whisk.EXIT_CODE_ERR_USAGE,
+            whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
+        return whiskErr
+    }
+
+    defer file.Close()
+
+    file.WriteString(content)
+
+    return nil
+}
+
+func fileExists(file string) (bool, error) {
 
 Review comment:
   maybe use this function inside other functions, such as `unpackGzip`, 
`unpackZip` and `unpackTar`
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to