From 2fcbc66838f03b0d7399708121b2e6657df8792c Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 14 Sep 2019 15:48:20 +0200 Subject: [PATCH] Follow some linter advices Signed-off-by: Knut Ahlers --- token.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/token.go b/token.go index 5431886..595c9ce 100644 --- a/token.go +++ b/token.go @@ -103,22 +103,23 @@ func useOrRenewToken(tok, accessToken string) (string, error) { if tok != "" { client.SetToken(tok) - if s, err := client.Auth().Token().LookupSelf(); err == nil && s.Data != nil { + s, err := client.Auth().Token().LookupSelf() + if err == nil && s.Data != nil { log.WithFields(log.Fields{"token": hashSecret(tok)}).Debugf("Token is valid for another %vs", s.Data["ttl"]) return tok, nil - } else { - log.WithFields(log.Fields{"token": hashSecret(tok)}).Debugf("Token did not met requirements: err = %s", err) - if s != nil { - log.WithFields(log.Fields{"token": hashSecret(tok)}).Debugf("Token did not met requirements: data = %v", s.Data) - } + } + + log.WithFields(log.Fields{"token": hashSecret(tok)}).Debugf("Token did not met requirements: err = %s", err) + if s != nil { + log.WithFields(log.Fields{"token": hashSecret(tok)}).Debugf("Token did not met requirements: data = %v", s.Data) } } - if s, err := client.Logical().Write("auth/github/login", map[string]interface{}{"token": accessToken}); err != nil || s.Auth == nil { + s, err := client.Logical().Write("auth/github/login", map[string]interface{}{"token": accessToken}) + if err != nil || s.Auth == nil { return "", fmt.Errorf("Login did not work: Error = %s", err) - } else { - return s.Auth.ClientToken, nil } + return s.Auth.ClientToken, nil } func getSecretsFromVault(tok string, next bool) ([]*token, error) {