Skip to content

Commit

Permalink
spelling modification
Browse files Browse the repository at this point in the history
Signed-off-by: Bill Hamilton <[email protected]>
  • Loading branch information
pacificcode committed Nov 7, 2024
1 parent d7827cf commit 23169cb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ type accessTokenResponse struct {
}

func (v Vault) setCacheAccessToken(value string, expiresIn int) bool {
percentage := 0.9
cache := TokenCache{}
cache.AccessToken = value
cache.ExpiresIn = (int(time.Now().Unix()) + expiresIn) - int(math.Floor(float64(expiresIn)*0.9))
cache.ExpiresIn = (int(time.Now().Unix()) + expiresIn) - int(math.Floor(float64(expiresIn)*percentage))

data, err := json.Marshal(cache)
if err != nil {
Expand Down Expand Up @@ -209,7 +210,6 @@ func (v Vault) getAccessToken() (string, error) {

request, err := json.Marshal(&rBody)
if err != nil {
return "", fmt.Errorf("marshalling token request body: %w", err)
}

url := v.urlFor("token", "")
Expand All @@ -222,7 +222,7 @@ func (v Vault) getAccessToken() (string, error) {
// TODO: cache the token until it expires.
resp := &accessTokenResponse{}
if err = json.Unmarshal(response, &resp); err != nil {
return "", fmt.Errorf("unmarshalling token response: %w", err)
return "", fmt.Errorf("unmarshaling token response: %w", err)
}
ok := v.setCacheAccessToken(resp.AccessToken, resp.ExpiresIn)
if !ok {
Expand Down

0 comments on commit 23169cb

Please sign in to comment.