You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ra...@apache.org on 2017/09/14 16:37:23 UTC

[incubator-openwhisk] branch master updated: Clarify WSK_CONFIG_FILE empty string behavior (#2357)

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

rabbah 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 8a9a57d  Clarify WSK_CONFIG_FILE empty string behavior (#2357)
8a9a57d is described below

commit 8a9a57d25e943e53841c5ce67e513f271124b0d3
Author: Mark Deuser <md...@us.ibm.com>
AuthorDate: Thu Sep 14 12:37:21 2017 -0400

    Clarify WSK_CONFIG_FILE empty string behavior (#2357)
    
    - add test and add comments.
---
 tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala | 6 ++++++
 tools/cli/go-whisk-cli/commands/property.go                   | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

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 8e34aea..795a26a 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskConfigTests.scala
@@ -53,6 +53,12 @@ class WskConfigTests extends TestHelpers with WskTestHelpers {
     }
   }
 
+  it should "use default cli configuration when an empty string WSK_CONFIG_FILE is supplied" in {
+    val env = Map("WSK_CONFIG_FILE" -> "")
+    val stderr = wsk.cli(Seq("property", "get", "-i"), env = env, expectedExitCode = ERROR_EXIT).stderr
+    stderr should include("The API host is not valid: An API host must be provided.")
+  }
+
   it should "validate default property values" in {
     val tmpwskprops = File.createTempFile("wskprops", ".tmp")
     val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
diff --git a/tools/cli/go-whisk-cli/commands/property.go b/tools/cli/go-whisk-cli/commands/property.go
index cfff7f1..27ad367 100644
--- a/tools/cli/go-whisk-cli/commands/property.go
+++ b/tools/cli/go-whisk-cli/commands/property.go
@@ -402,8 +402,11 @@ func SetDefaultProperties() {
 func GetPropertiesFilePath() (propsFilePath string, werr error) {
     var envExists bool
 
-    // Environment variable overrides the default properties file path
-    if propsFilePath, envExists = os.LookupEnv("WSK_CONFIG_FILE"); envExists == true || propsFilePath != "" {
+    // WSK_CONFIG_FILE environment variable overrides the default properties file path
+    // NOTE: If this variable is set to an empty string or non-existent/unreadable file
+    // - any existing $HOME/.wskprops is ignored
+    // - a default configuration is used
+    if propsFilePath, envExists = os.LookupEnv("WSK_CONFIG_FILE"); envExists {
         whisk.Debug(whisk.DbgInfo, "Using properties file '%s' from WSK_CONFIG_FILE environment variable\n", propsFilePath)
         return propsFilePath, nil
     } else {

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