format cleanup

This commit is contained in:
John Adams 2018-05-14 11:46:15 -07:00
parent 33dd3593c9
commit 5197566d20

View file

@ -16,11 +16,11 @@ package vault
* export VAULT_CACERT= ... pem file containing ca cert ... * export VAULT_CACERT= ... pem file containing ca cert ...
* and/or * and/or
* export VAULT_SSL_VERIFY=no * export VAULT_SSL_VERIFY=no
*/ */
import ( import (
"os"
"fmt" "fmt"
"os"
"time" "time"
"github.com/xordataexchange/crypt/backend" "github.com/xordataexchange/crypt/backend"
@ -38,8 +38,8 @@ type Client struct {
func (c *Client) acquireToken(role string, secret string) (string, error) { func (c *Client) acquireToken(role string, secret string) (string, error) {
secretData := map[string]interface{}{ secretData := map[string]interface{}{
"role_id" : role, "role_id": role,
"secret_id" : secret, "secret_id": secret,
} }
data, err := c.client.Logical().Write("auth/approle/login", secretData) 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 return "", err
} }
/* data is now of type *api.Secret and we can use it to set the client up */ /* 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 { if err == nil {
c.client.SetToken(token) 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 // this can be called before operations to ensure token is currentfg
func (c *Client) renewToken() (string, error) { func (c *Client) renewToken() (string, error) {
if c.secret_expires { 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")) return c.acquireToken(os.Getenv("VAULT_ROLE_ID"), os.Getenv("VAULT_SECRET_ID"))
} else { } else {
return "", nil return "", nil
@ -155,7 +155,7 @@ func (c *Client) Get(key string) ([]byte, error) {
} }
v := data.Data["value"].(string) v := data.Data["value"].(string)
return []byte(v) , nil return []byte(v), nil
} }
func (c *Client) List(key string) (backend.KVPairs, error) { func (c *Client) List(key string) (backend.KVPairs, error) {