Skip to content

Commit

Permalink
Add trace option for Vault
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmitchell committed Oct 16, 2019
1 parent 7f24c87 commit abf3247
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/ddayconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ backends:
# (string) This is the path to begin looking for Vault secrets. Everything under this
# path will be searched. Defaults to "secret/" if not present.
base_path: "secret/"
# (boolean) If set to true, requests to and responses from the Vault will
# be logged to stdout. You probably only want this if you're debugging.
#trace: true
#
# (hash) Options for authorizing to Vault
# Must either provide "token" for Token auth or "role_id" and "secret_id" for AppRole
# If a token is given, it should either have no expiry or be renewable.
Expand Down
11 changes: 10 additions & 1 deletion storage/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package storage
import (
"crypto/tls"
"fmt"
"io"
"net/http"
"net/url"
"os"
"regexp"
"runtime"
"strings"
Expand All @@ -27,6 +29,7 @@ type VaultConfig struct {
Address string `yaml:"address"`
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
BasePath string `yaml:"base_path"`
Trace bool `yaml:"trace"`
Auth struct {
Token string `yaml:"token"`
RoleID string `yaml:"role_id"`
Expand All @@ -52,6 +55,12 @@ func newVaultAccessor(conf VaultConfig) (*VaultAccessor, error) {
conf.BasePath = "secret/"
}

var tracer io.Writer
if conf.Trace {
//I'm already tracer
tracer = os.Stdout
}

client := &vaultkv.Client{
VaultURL: u,
AuthToken: conf.Auth.Token,
Expand All @@ -63,7 +72,7 @@ func newVaultAccessor(conf VaultConfig) (*VaultAccessor, error) {
MaxIdleConnsPerHost: runtime.NumCPU(),
},
},
//Trace: os.Stdout,
Trace: tracer,
}

var shouldRenew bool
Expand Down

0 comments on commit abf3247

Please sign in to comment.