Merge pull request #28864 from hashicorp/alisdair/fix-remote-backend-multi-workspace-state-migration
Fix remote backend multi workspace state migration
This commit is contained in:
commit
24ace6ae7d
|
@ -49,6 +49,7 @@ func (c *InitCommand) Run(args []string) int {
|
|||
cmdFlags.BoolVar(&flagUpgrade, "upgrade", false, "")
|
||||
cmdFlags.Var(&flagPluginPath, "plugin-dir", "plugin directory")
|
||||
cmdFlags.StringVar(&flagLockfile, "lockfile", "", "Set a dependency lockfile mode")
|
||||
cmdFlags.BoolVar(&c.Meta.ignoreRemoteVersion, "ignore-remote-version", false, "continue even if remote and local Terraform versions are incompatible")
|
||||
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
if err := cmdFlags.Parse(args); err != nil {
|
||||
return 1
|
||||
|
@ -1003,6 +1004,9 @@ Options:
|
|||
-lockfile=MODE Set a dependency lockfile mode.
|
||||
Currently only "readonly" is valid.
|
||||
|
||||
-ignore-remote-version A rare option used for the remote backend only. See
|
||||
the remote backend documentation for more information.
|
||||
|
||||
`
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ func (m *Meta) backendMigrateState(opts *backendMigrateOpts) error {
|
|||
errMigrateLoadStates), opts.OneType, err)
|
||||
}
|
||||
|
||||
_, err = opts.Two.Workspaces()
|
||||
twoWorkspaces, err := opts.Two.Workspaces()
|
||||
if err == backend.ErrWorkspacesNotSupported {
|
||||
twoSingle = true
|
||||
err = nil
|
||||
|
@ -77,13 +77,15 @@ func (m *Meta) backendMigrateState(opts *backendMigrateOpts) error {
|
|||
// as we are migrating away and will not break a remote workspace.
|
||||
m.ignoreRemoteBackendVersionConflict(opts.One)
|
||||
|
||||
for _, twoWorkspace := range twoWorkspaces {
|
||||
// Check the remote Terraform version for the state destination backend. If
|
||||
// it's a Terraform Cloud remote backend, we want to ensure that we don't
|
||||
// break the workspace by uploading an incompatible state file.
|
||||
diags := m.remoteBackendVersionCheck(opts.Two, opts.twoEnv)
|
||||
diags := m.remoteBackendVersionCheck(opts.Two, twoWorkspace)
|
||||
if diags.HasErrors() {
|
||||
return diags.Err()
|
||||
}
|
||||
}
|
||||
|
||||
// Determine migration behavior based on whether the source/destination
|
||||
// supports multi-state.
|
||||
|
|
Loading…
Reference in New Issue