open-vault/command/config/util.go
mickael-hc 3e4f7db237
dev docs: clarify internal and external token helpers (#13014)
* dev docs: clarify internal and external token helpers

* Add docs for DefaultTokenHelper
2022-08-16 16:48:24 -04:00

26 lines
574 B
Go

package config
import (
"github.com/hashicorp/vault/command/token"
)
// DefaultTokenHelper returns the token helper that is configured for Vault.
// This helper should only be used for non-server CLI commands.
func DefaultTokenHelper() (token.TokenHelper, error) {
config, err := LoadConfig("")
if err != nil {
return nil, err
}
path := config.TokenHelper
if path == "" {
return token.NewInternalTokenHelper()
}
path, err = token.ExternalTokenHelperPath(path)
if err != nil {
return nil, err
}
return &token.ExternalTokenHelper{BinaryPath: path}, nil
}