[GitHub] [openwhisk-wskdeploy] mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set
mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set URL: https://github.com/apache/openwhisk-wskdeploy/pull/1054#discussion_r321441197 ## File path: cmd/root.go ## @@ -102,21 +102,32 @@ func init() { func initConfig() { userHome := utils.GetHomeDirectory() defaultPath := path.Join(userHome, whisk.DEFAULT_LOCAL_CONFIG) - if utils.Flags.CfgFile != "" { - // Read the file as a wskprops file, to check if it is valid. - _, err := whisk.ReadProps(utils.Flags.CfgFile) - if err != nil { - utils.Flags.CfgFile = defaultPath - warn := wski18n.T(wski18n.ID_WARN_CONFIG_INVALID_X_path_X, - map[string]interface{}{ - wski18n.KEY_PATH: utils.Flags.CfgFile}) - wskprint.PrintOpenWhiskWarning(warn) +// Precedence order for reading the configuration file should be: +// 1. --config +// 2. ENV variable WSK_CONFIG_FILE +// 3. Default $HOME/.wskprops + cfgFiles := []string{ + utils.Flags.CfgFile, + os.Getenv("WSK_CONFIG_FILE"), +defaultPath, +} + + for _, cfgFile := range cfgFiles { Review comment: Can you please clarify "not a gopher" for me? This is an automated message from the Apache Git Service. To respond to the message, please log on to 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
[GitHub] [openwhisk-wskdeploy] mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set
mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set URL: https://github.com/apache/openwhisk-wskdeploy/pull/1054#discussion_r315757648 ## File path: cmd/root.go ## @@ -102,21 +102,32 @@ func init() { func initConfig() { userHome := utils.GetHomeDirectory() defaultPath := path.Join(userHome, whisk.DEFAULT_LOCAL_CONFIG) - if utils.Flags.CfgFile != "" { - // Read the file as a wskprops file, to check if it is valid. - _, err := whisk.ReadProps(utils.Flags.CfgFile) - if err != nil { - utils.Flags.CfgFile = defaultPath - warn := wski18n.T(wski18n.ID_WARN_CONFIG_INVALID_X_path_X, - map[string]interface{}{ - wski18n.KEY_PATH: utils.Flags.CfgFile}) - wskprint.PrintOpenWhiskWarning(warn) +// Precedence order for reading the configuration file should be: +// 1. --config +// 2. ENV variable WSK_CONFIG_FILE +// 3. Default $HOME/.wskprops + cfgFiles := []string{ + utils.Flags.CfgFile, + os.Getenv("WSK_CONFIG_FILE"), +defaultPath, +} + + for _, cfgFile := range cfgFiles { Review comment: validating each in priority order and discontinuing search (short circuit) on first valid (success) config file seems much more efficient. That is why, bother looking for WSK_CONFIG_FILE at all if --config file is valid? etc. This is an automated message from the Apache Git Service. To respond to the message, please log on to 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
[GitHub] [openwhisk-wskdeploy] mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set
mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set URL: https://github.com/apache/openwhisk-wskdeploy/pull/1054#discussion_r315757648 ## File path: cmd/root.go ## @@ -102,21 +102,32 @@ func init() { func initConfig() { userHome := utils.GetHomeDirectory() defaultPath := path.Join(userHome, whisk.DEFAULT_LOCAL_CONFIG) - if utils.Flags.CfgFile != "" { - // Read the file as a wskprops file, to check if it is valid. - _, err := whisk.ReadProps(utils.Flags.CfgFile) - if err != nil { - utils.Flags.CfgFile = defaultPath - warn := wski18n.T(wski18n.ID_WARN_CONFIG_INVALID_X_path_X, - map[string]interface{}{ - wski18n.KEY_PATH: utils.Flags.CfgFile}) - wskprint.PrintOpenWhiskWarning(warn) +// Precedence order for reading the configuration file should be: +// 1. --config +// 2. ENV variable WSK_CONFIG_FILE +// 3. Default $HOME/.wskprops + cfgFiles := []string{ + utils.Flags.CfgFile, + os.Getenv("WSK_CONFIG_FILE"), +defaultPath, +} + + for _, cfgFile := range cfgFiles { Review comment: validating each in priority order and discontinuing search (short circuit) on first valid (success) config file seems much more efficient. That is why, bother looking for WSK_CONFIG_FILE at all if --config file is valid? etc. This is an automated message from the Apache Git Service. To respond to the message, please log on to 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
[GitHub] [openwhisk-wskdeploy] mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set
mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set URL: https://github.com/apache/openwhisk-wskdeploy/pull/1054#discussion_r315757648 ## File path: cmd/root.go ## @@ -102,21 +102,32 @@ func init() { func initConfig() { userHome := utils.GetHomeDirectory() defaultPath := path.Join(userHome, whisk.DEFAULT_LOCAL_CONFIG) - if utils.Flags.CfgFile != "" { - // Read the file as a wskprops file, to check if it is valid. - _, err := whisk.ReadProps(utils.Flags.CfgFile) - if err != nil { - utils.Flags.CfgFile = defaultPath - warn := wski18n.T(wski18n.ID_WARN_CONFIG_INVALID_X_path_X, - map[string]interface{}{ - wski18n.KEY_PATH: utils.Flags.CfgFile}) - wskprint.PrintOpenWhiskWarning(warn) +// Precedence order for reading the configuration file should be: +// 1. --config +// 2. ENV variable WSK_CONFIG_FILE +// 3. Default $HOME/.wskprops + cfgFiles := []string{ + utils.Flags.CfgFile, + os.Getenv("WSK_CONFIG_FILE"), +defaultPath, +} + + for _, cfgFile := range cfgFiles { Review comment: validating each in order and discontinuing search (short circuit) on first valid (success) config file seems much more efficient. This is an automated message from the Apache Git Service. To respond to the message, please log on to 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
[GitHub] [openwhisk-wskdeploy] mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set
mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set URL: https://github.com/apache/openwhisk-wskdeploy/pull/1054#discussion_r315757648 ## File path: cmd/root.go ## @@ -102,21 +102,32 @@ func init() { func initConfig() { userHome := utils.GetHomeDirectory() defaultPath := path.Join(userHome, whisk.DEFAULT_LOCAL_CONFIG) - if utils.Flags.CfgFile != "" { - // Read the file as a wskprops file, to check if it is valid. - _, err := whisk.ReadProps(utils.Flags.CfgFile) - if err != nil { - utils.Flags.CfgFile = defaultPath - warn := wski18n.T(wski18n.ID_WARN_CONFIG_INVALID_X_path_X, - map[string]interface{}{ - wski18n.KEY_PATH: utils.Flags.CfgFile}) - wskprint.PrintOpenWhiskWarning(warn) +// Precedence order for reading the configuration file should be: +// 1. --config +// 2. ENV variable WSK_CONFIG_FILE +// 3. Default $HOME/.wskprops + cfgFiles := []string{ + utils.Flags.CfgFile, + os.Getenv("WSK_CONFIG_FILE"), +defaultPath, +} + + for _, cfgFile := range cfgFiles { Review comment: validating each in order and discontinuing search (short circuit) on first success seems much more efficient. This is an automated message from the Apache Git Service. To respond to the message, please log on to 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
[GitHub] [openwhisk-wskdeploy] mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set
mrutkows commented on a change in pull request #1054: Honor WSK_CONFIG_FILE if variable is set URL: https://github.com/apache/openwhisk-wskdeploy/pull/1054#discussion_r315755456 ## File path: cmd/root.go ## @@ -102,21 +102,32 @@ func init() { func initConfig() { userHome := utils.GetHomeDirectory() defaultPath := path.Join(userHome, whisk.DEFAULT_LOCAL_CONFIG) - if utils.Flags.CfgFile != "" { - // Read the file as a wskprops file, to check if it is valid. - _, err := whisk.ReadProps(utils.Flags.CfgFile) - if err != nil { - utils.Flags.CfgFile = defaultPath - warn := wski18n.T(wski18n.ID_WARN_CONFIG_INVALID_X_path_X, - map[string]interface{}{ - wski18n.KEY_PATH: utils.Flags.CfgFile}) - wskprint.PrintOpenWhiskWarning(warn) +// Precedence order for reading the configuration file should be: +// 1. --config +// 2. ENV variable WSK_CONFIG_FILE +// 3. Default $HOME/.wskprops + cfgFiles := []string{ + utils.Flags.CfgFile, + os.Getenv("WSK_CONFIG_FILE"), +defaultPath, +} + + for _, cfgFile := range cfgFiles { Review comment: If indeed there are 3 discrete places we look for a valid config. file (and each should have a single entry/key and associated value), then using an array to loop upon with a break stmt. seems overkill. This is an automated message from the Apache Git Service. To respond to the message, please log on to 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