From 654131be96957090255297fb7214b9c3193e6506 Mon Sep 17 00:00:00 2001 From: Alessandro Valcepina Date: Mon, 13 Jan 2020 08:22:03 +0100 Subject: [PATCH 1/2] Cleaning token store when logging in --- cmd/login.go | 4 ++++ cmd/root.go | 4 ++-- semver/version.go | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/login.go b/cmd/login.go index cefb5ed..f20afb1 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -119,8 +119,12 @@ Example: if err != nil { return err } + Config.Token = refreshToken } + + TokenStore.Clean() + Config.Username = Username fmt.Println("Login Successful.") writeConfigError := WriteConfigFile() diff --git a/cmd/root.go b/cmd/root.go index 78f0cfa..e0da54c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -71,12 +71,12 @@ var kubeConfigPath string var TokenStore client.TokenStore // version should be in format d.d.d where d is a decimal number -const Version string = semver.Version //"v0.0.61" +const Version string = semver.Version //"v0.0.63" var AppName string = InitAppName() // Backend version is the version this client is tested with -const BackendVersion string = "0.7.13" +const BackendVersion string = "0.8.17" /* Application name can change over time so it is made parameteric diff --git a/semver/version.go b/semver/version.go index 7105f37..6b4eb44 100644 --- a/semver/version.go +++ b/semver/version.go @@ -1,4 +1,5 @@ package version + // This package is auto generated please don't edit manually -const Version string = "v0.0.62" +const Version string = "v0.0.63" From bba675fb38c469be0e4e047b2a81275cc895c32a Mon Sep 17 00:00:00 2001 From: Alessandro Valcepina Date: Tue, 14 Jan 2020 08:38:33 +0100 Subject: [PATCH 2/2] Changed the way token store is cleaned when logging in --- cmd/login.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/login.go b/cmd/login.go index f20afb1..31f01ab 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -18,7 +18,7 @@ import ( "errors" "fmt" "syscall" - + "io/ioutil" "github.com/magneticio/vampkubistcli/client" "github.com/magneticio/vampkubistcli/logging" "github.com/magneticio/vampkubistcli/util" @@ -91,6 +91,17 @@ Example: } Config.Cert = CertString } + + tmpfile, tempFileError := ioutil.TempFile("", "tokenstore") + if tempFileError != nil { + logging.Error("Token Store file can not be read due to error: %v\n", tempFileError) + } + + Config.TokenStorePath = tmpfile.Name() + TokenStore = &client.FileBackedTokenStore{ + Path: Config.TokenStorePath, + } + if Token != "" { Config.Token = Token restClient := client.NewRestClient(Config.Url, Config.Token, Config.APIVersion, logging.Verbose, Config.Cert, &TokenStore) @@ -123,8 +134,6 @@ Example: Config.Token = refreshToken } - TokenStore.Clean() - Config.Username = Username fmt.Println("Login Successful.") writeConfigError := WriteConfigFile()