dubeejw closed pull request #2772: Fix issue with trailing spaces and handle
comments in the property file.
URL: https://github.com/apache/incubator-openwhisk/pull/2772
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
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 795a26a9c3..e4e14e9215 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 e8c422fa90..2bf6118755 100644
--- a/tools/cli/go-whisk-cli/commands/util.go
+++ b/tools/cli/go-whisk-cli/commands/util.go
@@ -39,6 +39,7 @@ import (
"sort"
"reflect"
"bytes"
+ "regexp"
)
func csvToQualifiedActions(artifacts string) ([]string) {
@@ -956,6 +957,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
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services