Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #86 from magneticio/bugfix/LAM-530/token-on-login
Browse files Browse the repository at this point in the history
Cleaning token store when logging in
  • Loading branch information
avalcepina authored Jan 14, 2020
2 parents 5f9ff6d + bba675f commit ec116ed
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
15 changes: 14 additions & 1 deletion cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -119,8 +130,10 @@ Example:
if err != nil {
return err
}

Config.Token = refreshToken
}

Config.Username = Username
fmt.Println("Login Successful.")
writeConfigError := WriteConfigFile()
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion semver/version.go
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit ec116ed

Please sign in to comment.