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 73E27200CC9 for ; Mon, 17 Jul 2017 14:06:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7224B164CB2; Mon, 17 Jul 2017 12:06:10 +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 B9A79164C92 for ; Mon, 17 Jul 2017 14:06:09 +0200 (CEST) Received: (qmail 29329 invoked by uid 500); 17 Jul 2017 12:06:09 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 29320 invoked by uid 99); 17 Jul 2017 12:06:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jul 2017 12:06:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D4315DFAE0; Mon, 17 Jul 2017 12:06:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sjcorbett@apache.org To: commits@brooklyn.apache.org Date: Mon, 17 Jul 2017 12:06:08 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/18] brooklyn-client git commit: Ignore invalid config during login and remove config upon failure archived-at: Mon, 17 Jul 2017 12:06:10 -0000 Repository: brooklyn-client Updated Branches: refs/heads/master 052d3bdae -> be8051602 Ignore invalid config during login and remove config upon failure Project: http://git-wip-us.apache.org/repos/asf/brooklyn-client/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-client/commit/bca4c072 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-client/tree/bca4c072 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-client/diff/bca4c072 Branch: refs/heads/master Commit: bca4c0729b2a41c88ffe814c28da63d2dffca147 Parents: 653e4f4 Author: Geoff Macartney Authored: Wed May 24 20:43:08 2017 +0100 Committer: Geoff Macartney Committed: Tue Jul 4 11:06:00 2017 +0100 ---------------------------------------------------------------------- cli/br/brooklyn.go | 6 +++++- cli/commands/login.go | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/bca4c072/cli/br/brooklyn.go ---------------------------------------------------------------------- diff --git a/cli/br/brooklyn.go b/cli/br/brooklyn.go index 3250a8f..b753d42 100644 --- a/cli/br/brooklyn.go +++ b/cli/br/brooklyn.go @@ -34,7 +34,7 @@ func main() { config := io.GetConfig() skipSslChecks := config.GetSkipSslChecks() target, username, password, err := config.GetNetworkCredentials() - if err != nil { + if err != nil && !isLogin(os.Args) { error_handler.ErrorExit(err) } @@ -50,3 +50,7 @@ func main() { error_handler.ErrorExit(err) } } + +func isLogin(args []string) bool { + return len(args) > 1 && args[1] == "login" +} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/bca4c072/cli/commands/login.go ---------------------------------------------------------------------- diff --git a/cli/commands/login.go b/cli/commands/login.go index a0459ca..78f8852 100644 --- a/cli/commands/login.go +++ b/cli/commands/login.go @@ -93,6 +93,9 @@ func (cmd *Login) Run(scope scope.Scope, c *cli.Context) { cmd.network.BrooklynPass = c.Args().Get(2) cmd.network.SkipSslChecks = c.Bool("skipSslChecks") + // invalidate current credentials record + io.GetConfig().Delete() + if err := net.VerifyLoginURL(cmd.network); err != nil { error_handler.ErrorExit(err) } @@ -125,6 +128,7 @@ func (cmd *Login) Run(scope scope.Scope, c *cli.Context) { if code == http.StatusUnauthorized { err = errors.New("Unauthorized") } + cmd.config.Delete() error_handler.ErrorExit(err) } fmt.Printf("Connected to Brooklyn version %s at %s\n", loginVersion.Version, cmd.network.BrooklynUrl)