cli: Fix state migration version check
When migrating multiple local workspaces to a remote backend target using the `prefix` argument, we need to perform the version check against all existing workspaces returned by the `Workspaces` method. Failing to do so will result in a version check error.
This commit is contained in:
parent
19313980b7
commit
6692336541
|
@ -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