mirror of
https://github.com/hashicorp/terraform.git
synced 2026-05-28 04:03:27 -04:00
command/cliconfig: EmptyCredentialsSourceForTests
A more convenient interface to get a throwaway empty credentials source for use in tests, which doesn't interact at all with the real CLI configuration directory.
This commit is contained in:
parent
bc9756882e
commit
c4076fe6a2
1 changed files with 11 additions and 0 deletions
|
|
@ -64,6 +64,17 @@ func (c *Config) CredentialsSource(helperPlugins pluginDiscovery.PluginMetaSet)
|
|||
return c.credentialsSource(helperType, helper, credentialsFilePath), nil
|
||||
}
|
||||
|
||||
// EmptyCredentialsSourceForTests constructs a CredentialsSource with
|
||||
// no credentials pre-loaded and which writes new credentials to a file
|
||||
// at the given path.
|
||||
//
|
||||
// As the name suggests, this function is here only for testing and should not
|
||||
// be used in normal application code.
|
||||
func EmptyCredentialsSourceForTests(credentialsFilePath string) *CredentialsSource {
|
||||
cfg := &Config{}
|
||||
return cfg.credentialsSource("", nil, credentialsFilePath)
|
||||
}
|
||||
|
||||
// credentialsSource is an internal factory for the credentials source which
|
||||
// allows overriding the credentials file path, which allows setting it to
|
||||
// a temporary file location when testing.
|
||||
|
|
|
|||
Loading…
Reference in a new issue