mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-11 09:07:00 +02:00
* Move command/config + command/token to api/cliconfig + api/tokenhelper * Remove unused functions and unused import * Simplify and inline function copied from SDK * Delete unused duplicated/forwarding config implementation from command package * Delete unused code, unexport API surface that's only used internally to the package * Fix up license headers * Add changelog * Tweak .gitignore to track hcl files in testdata/ folders
29 lines
673 B
Go
29 lines
673 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package cliconfig
|
|
|
|
import (
|
|
"github.com/hashicorp/vault/api/tokenhelper"
|
|
)
|
|
|
|
// DefaultTokenHelper returns the token helper that is configured for Vault.
|
|
// This helper should only be used for non-server CLI commands.
|
|
func DefaultTokenHelper() (tokenhelper.TokenHelper, error) {
|
|
config, err := loadConfig("")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
path := config.TokenHelper
|
|
if path == "" {
|
|
return tokenhelper.NewInternalTokenHelper()
|
|
}
|
|
|
|
path, err = tokenhelper.ExternalTokenHelperPath(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &tokenhelper.ExternalTokenHelper{BinaryPath: path}, nil
|
|
}
|