This is an automated email from the ASF dual-hosted git repository. houshengbo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit a65c3cb8592c99de2e7060d1415225f9deffd39f Author: Mark Deuser <[email protected]> AuthorDate: Fri Jul 14 14:40:18 2017 -0400 Externalize access to a few CLI methods to facilitate access across packages (#2483) - Also move properties file reading/loading to when the command is executed, not at binary load time --- commands/commands.go | 17 +++++++++-------- commands/property.go | 6 +++--- wski18n/resources/en_US.all.json | 4 ++++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/commands/commands.go b/commands/commands.go index 5020ea2..d943f6a 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -19,7 +19,6 @@ package commands import ( "errors" - "fmt" "net/http" "os" @@ -75,14 +74,7 @@ func setupClientConfig(cmd *cobra.Command, args []string) (error){ } func init() { - var err error - err = loadProperties() - if err != nil { - whisk.Debug(whisk.DbgError, "loadProperties() error: %s\n", err) - fmt.Println(err) - os.Exit(whisk.EXITCODE_ERR_GENERAL) - } } func getKeyValueArgs(args []string, argIndex int, parsedArgs []string) ([]string, []string, error) { @@ -211,5 +203,14 @@ func Execute() error { return whiskErr } + err = loadProperties() + if err != nil { + whisk.Debug(whisk.DbgError, "loadProperties() error: %s\n", err) + errMsg := wski18n.T("Unable to access configuration properties: {{.err}}", map[string]interface{}{"err":err}) + whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL, + whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE) + return whiskErr + } + return WskCmd.Execute() } diff --git a/commands/property.go b/commands/property.go index 4a2a7e7..a29ab14 100644 --- a/commands/property.go +++ b/commands/property.go @@ -349,7 +349,7 @@ func setDefaultProperties() { // Properties.CLIVersion value is set from main's init() } -func getPropertiesFilePath() (propsFilePath string, werr error) { +func GetPropertiesFilePath() (propsFilePath string, werr error) { var envExists bool // Environment variable overrides the default properties file path @@ -381,10 +381,10 @@ func loadProperties() error { setDefaultProperties() - Properties.PropsFile, err = getPropertiesFilePath() + Properties.PropsFile, err = GetPropertiesFilePath() if err != nil { return nil - //whisk.Debug(whisk.DbgError, "getPropertiesFilePath() failed: %s\n", err) + //whisk.Debug(whisk.DbgError, "GetPropertiesFilePath() failed: %s\n", err) //errStr := fmt.Sprintf("Unable to load the properties file: %s", err) //werr := whisk.MakeWskError(errors.New(errStr), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) //return werr diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json index 535f958..7d3929e 100644 --- a/wski18n/resources/en_US.all.json +++ b/wski18n/resources/en_US.all.json @@ -381,6 +381,10 @@ "translation": "Unable to read the properties file '{{.filename}}': {{.err}}" }, { + "id": "Unable to access configuration properties: {{.err}}", + "translation": "Unable to access configuration properties: {{.err}}" + }, + { "id": "Invalid host address '{{.host}}': {{.err}}", "translation": "Invalid host address '{{.host}}': {{.err}}" }, -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
