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

+3 -2
View File
@@ -30,7 +30,7 @@ const (
maxLineLength int = 78
envToken = "BOUNDARY_TOKEN"
envTokenName = "BOUNDARY_TOKEN_NAME"
EnvTokenName = "BOUNDARY_TOKEN_NAME"
envRecoveryConfig = "BOUNDARY_RECOVERY_CONFIG"
)
@@ -207,6 +207,7 @@ func (c *Command) Client(opt ...Option) (*api.Client, error) {
if c.FlagTokenName != "" {
tokenName = c.FlagTokenName
}
os.Setenv(EnvTokenName, tokenName)
if tokenName != "none" {
token, err := keyring.Get("HashiCorp Boundary Auth Token", tokenName)
if err != nil {
@@ -329,7 +330,7 @@ func (c *Command) FlagSet(bit FlagSetBit) *FlagSets {
f.StringVar(&StringVar{
Name: "token-name",
Target: &c.FlagTokenName,
EnvVar: envTokenName,
EnvVar: EnvTokenName,
Usage: `If specified, the given value will be used as the name when storing the token in the system credential store. This can allow switching user identities for different commands. Set to "none" to disable storing the token.`,
})