Add boundary config get-token (#455)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-09-25 17:06:53 -04:00
1 parent e2f3b2b706
commit 220ca253be
6 files changed
+111 -6

No files matched your search

+10 -1
View File
@@ -2,6 +2,7 @@ package api
import (
"fmt"
"os"
"strings"
retryablehttp "github.com/hashicorp/go-retryablehttp"
@@ -47,7 +48,15 @@ func (d *OutputStringError) parseRequest() {
for k, v := range d.Request.Header {
for _, h := range v {
if strings.ToLower(k) == "authorization" {
h = `Bearer <token>`
env := os.Getenv("BOUNDARY_TOKEN_NAME")
switch env {
case "none":
h = `Bearer <token>`
case "":
h = `Bearer $(boundary config get-token)`
default:
h = fmt.Sprintf("Bearer $(boundary config get-token -token-name %s)", env)
}
}
d.parsedCurlString = fmt.Sprintf("%s-H \"%s: %s\" ", d.parsedCurlString, k, h)
}