brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [01/18] brooklyn-client git commit: Ignore invalid config during login and remove config upon failure
Date Mon, 17 Jul 2017 12:06:08 GMT
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 <geoff.macartney@cloudsoftcorp.com>
Authored: Wed May 24 20:43:08 2017 +0100
Committer: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
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)


Mime
View raw message