Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8FC26200CD7 for ; Mon, 17 Jul 2017 16:10:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8E36C1632E4; Mon, 17 Jul 2017 14:10:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D193B163363 for ; Mon, 17 Jul 2017 16:10:29 +0200 (CEST) Received: (qmail 78063 invoked by uid 500); 17 Jul 2017 14:10:28 -0000 Mailing-List: contact commits-help@openwhisk.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwhisk.apache.org Delivered-To: mailing list commits@openwhisk.apache.org Received: (qmail 77964 invoked by uid 99); 17 Jul 2017 14:10:28 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jul 2017 14:10:28 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 9BFD4811C5; Mon, 17 Jul 2017 14:10:24 +0000 (UTC) Date: Mon, 17 Jul 2017 14:10:27 +0000 To: "commits@openwhisk.apache.org" Subject: [incubator-openwhisk-cli] 04/09: Externalize access to a few CLI methods to facilitate access across packages (#2483) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: houshengbo@apache.org Reply-To: "commits@openwhisk.apache.org" In-Reply-To: <150030062398.29376.9568996547021200763@gitbox.apache.org> References: <150030062398.29376.9568996547021200763@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-openwhisk-cli X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: a65c3cb8592c99de2e7060d1415225f9deffd39f X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20170717141025.9BFD4811C5@gitbox.apache.org> archived-at: Mon, 17 Jul 2017 14:10:30 -0000 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 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 "commits@openwhisk.apache.org" .