mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
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:
parent
79e985366f
commit
ba84faf4e1
@ -976,7 +976,8 @@ func TestInit_pluginDirReset(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure we remove the plugin-dir record
|
// 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)
|
t.Fatalf("bad: \n%s", ui.ErrorWriter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,9 +113,14 @@ func (r *multiVersionProviderResolver) ResolveProviders(
|
|||||||
|
|
||||||
// store the user-supplied path for plugin discovery
|
// store the user-supplied path for plugin discovery
|
||||||
func (m *Meta) storePluginPath(pluginPath []string) error {
|
func (m *Meta) storePluginPath(pluginPath []string) error {
|
||||||
|
if len(pluginPath) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
path := filepath.Join(m.DataDir(), PluginPathFile)
|
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)
|
err := os.Remove(path)
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user