This is an automated email from the ASF dual-hosted git repository.

dubeejw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 4828692  Fix issue with trailing spaces and handle comments in the 
property file. (#2772)
4828692 is described below

commit 48286925e6a26eae696dc5d69fa39ae99847794a
Author: Gabriel Nicolas Avellaneda <avellaneda.gabr...@gmail.com>
AuthorDate: Fri Oct 20 01:54:19 2017 -0200

    Fix issue with trailing spaces and handle comments in the property file. 
(#2772)
    
    * Fix issue with trailing spaces and handle comments in the property file.
    
    * Cleanup to follow coding style
    
    * Added Scala test for verifying that wskprops can correctly handle 
trailing white spaces and comments
    
    * Added spaces after the comment
---
 .../test/scala/whisk/core/cli/test/WskConfigTests.scala    | 14 ++++++++++++++
 tools/cli/go-whisk-cli/commands/util.go                    |  4 ++++
 2 files changed, 18 insertions(+)

diff --git a/tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala 
b/tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala
index 795a26a..e4e14e9 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala
@@ -132,6 +132,20 @@ class WskConfigTests extends TestHelpers with 
WskTestHelpers {
     }
   }
 
+  it should "get apihost removing any trailing white spaces and line comments" 
in {
+    val tmpwskprops = File.createTempFile("wskprops", ".tmp")
+    try {
+      val writer = new BufferedWriter(new FileWriter(tmpwskprops))
+      writer.write(s"APIHOST=http://localhost:10001    # This is a comment!   
")
+      writer.close()
+      val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
+      val stdout = wsk.cli(Seq("property", "get", "-i", "--apihost"), env = 
env).stdout
+      stdout should include regex ("whisk API host\\s+http://localhost:10001$";)
+    } finally {
+      tmpwskprops.delete()
+    }
+  }
+
   it should "set apihost, auth, and namespace" in {
     val tmpwskprops = File.createTempFile("wskprops", ".tmp")
     try {
diff --git a/tools/cli/go-whisk-cli/commands/util.go 
b/tools/cli/go-whisk-cli/commands/util.go
index 063c7db..bfcd2c6 100644
--- a/tools/cli/go-whisk-cli/commands/util.go
+++ b/tools/cli/go-whisk-cli/commands/util.go
@@ -38,6 +38,7 @@ import (
     "sort"
     "reflect"
     "bytes"
+    "regexp"
 )
 
 func csvToQualifiedActions(artifacts string) ([]string) {
@@ -1015,6 +1016,9 @@ func ReadProps(path string) (map[string]string, error) {
 
     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

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].

Reply via email to