remove the plugin path only for an empty string

To avoid breaking automation where plugin-path was assumed to be set
permanently, only remove the plugin-path record if it was explicitly set
to and empty string.
This commit is contained in:
James Bardin 2018-01-04 16:49:45 -05:00
parent 79e985366f
commit ba84faf4e1
2 changed files with 8 additions and 2 deletions

View File

@ -976,7 +976,8 @@ func TestInit_pluginDirReset(t *testing.T) {
}
// make sure we remove the plugin-dir record
if code := c.Run(nil); code != 0 {
args = []string{"-plugin-dir="}
if code := c.Run(args); code != 0 {
t.Fatalf("bad: \n%s", ui.ErrorWriter)
}

View File

@ -113,9 +113,14 @@ func (r *multiVersionProviderResolver) ResolveProviders(
// store the user-supplied path for plugin discovery
func (m *Meta) storePluginPath(pluginPath []string) error {
if len(pluginPath) == 0 {
return nil
}
path := filepath.Join(m.DataDir(), PluginPathFile)
if len(pluginPath) == 0 {
// remove the plugin dir record if the path was set to an empty string
if len(pluginPath) == 1 && (pluginPath[0] == "") {
err := os.Remove(path)
if !os.IsNotExist(err) {
return err