mirror of
https://github.com/spf13/viper
synced 2024-12-24 12:37:02 +00:00
format cleanup
This commit is contained in:
parent
33dd3593c9
commit
5197566d20
1 changed files with 94 additions and 94 deletions
|
@ -16,11 +16,11 @@ package vault
|
|||
* export VAULT_CACERT= ... pem file containing ca cert ...
|
||||
* and/or
|
||||
* export VAULT_SSL_VERIFY=no
|
||||
*/
|
||||
*/
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/xordataexchange/crypt/backend"
|
||||
|
@ -38,8 +38,8 @@ type Client struct {
|
|||
|
||||
func (c *Client) acquireToken(role string, secret string) (string, error) {
|
||||
secretData := map[string]interface{}{
|
||||
"role_id" : role,
|
||||
"secret_id" : secret,
|
||||
"role_id": role,
|
||||
"secret_id": secret,
|
||||
}
|
||||
|
||||
data, err := c.client.Logical().Write("auth/approle/login", secretData)
|
||||
|
@ -47,7 +47,7 @@ func (c *Client) acquireToken(role string, secret string) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
/* data is now of type *api.Secret and we can use it to set the client up */
|
||||
token,err := data.TokenID()
|
||||
token, err := data.TokenID()
|
||||
if err == nil {
|
||||
c.client.SetToken(token)
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ func (c *Client) acquireToken(role string, secret string) (string, error) {
|
|||
// this can be called before operations to ensure token is currentfg
|
||||
func (c *Client) renewToken() (string, error) {
|
||||
if c.secret_expires {
|
||||
if ((c.secret_ttl.Seconds() + c.secret_acq_at > float64(time.Now().Unix())) && c.secret_ttl != 0) {
|
||||
if (c.secret_ttl.Seconds()+c.secret_acq_at > float64(time.Now().Unix())) && c.secret_ttl != 0 {
|
||||
return c.acquireToken(os.Getenv("VAULT_ROLE_ID"), os.Getenv("VAULT_SECRET_ID"))
|
||||
} else {
|
||||
return "", nil
|
||||
|
@ -155,7 +155,7 @@ func (c *Client) Get(key string) ([]byte, error) {
|
|||
}
|
||||
|
||||
v := data.Data["value"].(string)
|
||||
return []byte(v) , nil
|
||||
return []byte(v), nil
|
||||
}
|
||||
|
||||
func (c *Client) List(key string) (backend.KVPairs, error) {
|
||||
|
|
Loading…
Reference in a new issue