command: backendConfig must mutate its copy, not the original

Here we were going to the trouble of copying the body so we could mutate
it, but then ended up mutating the original anyway and then returning the
unmodified copy. Whoops!

This fix is verified by a number of "init" command tests that exercise the
-backend-config option, including TestInit_backendConfigFile and several
others whose names have the prefix TestInit_backendConfig .
This commit is contained in:
Martin Atkins 2018-11-08 17:08:32 -08:00
parent f001cb8654
commit b5547f00f6
1 changed files with 1 additions and 1 deletions

View File

@ -329,7 +329,7 @@ func (m *Meta) backendConfig(opts *BackendOpts) (*configs.Backend, int, tfdiags.
// We'll shallow-copy configs.Backend here so that we can replace the
// body without affecting others that hold this reference.
configCopy := *c
c.Config = configBody
configCopy.Config = configBody
return &configCopy, configHash, diags
}