Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Terraform
Commits
85ae1cdd
Commit
85ae1cdd
authored
3 years ago
by
Chris Arcand
Browse files
Options
Download
Email Patches
Plain Diff
backport of commit
6f25ad3e
parent
4c040b78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
internal/command/meta_backend_migrate.go
+29
-8
internal/command/meta_backend_migrate.go
with
29 additions
and
8 deletions
+29
-8
internal/command/meta_backend_migrate.go
+
29
-
8
View file @
85ae1cdd
package
command
import
(
"bytes"
"context"
"errors"
"fmt"
...
...
@@ -666,28 +667,48 @@ func (m *Meta) backendMigrateState_S_TFC(opts *backendMigrateOpts, sourceWorkspa
}
// After migrating multiple workspaces, we need to reselect the current workspace as it may
// have been renamed. Query the backend first to be sure it now exists, and if it does,
// select it.
// have been renamed. Query the backend first to be sure it now exists.
workspaces
,
err
:=
opts
.
Destination
.
Workspaces
()
if
err
!=
nil
{
return
err
}
var
workspacePresent
bool
for
_
,
name
:=
range
workspaces
{
if
name
==
newCurrentWorkspace
{
if
err
=
m
.
SetWorkspace
(
name
);
err
!=
nil
{
return
err
}
return
nil
workspacePresent
=
true
}
}
// If we couldn't select the workspace automatically from the backend (maybe it was empty
// and wasn't migrated, for instance), ask the user to select one.
if
err
=
m
.
selectWorkspace
(
opts
.
Destination
);
err
!=
nil
{
// and wasn't migrated, for instance), ask the user to select one instead and be done.
if
!
workspacePresent
{
if
err
=
m
.
selectWorkspace
(
opts
.
Destination
);
err
!=
nil
{
return
err
}
return
nil
}
// The newly renamed current workspace is present, so we'll automatically select it for the
// user, as well as display the equivalent of 'workspace list' to show how the workspaces
// were changed (as well as the newly selected current workspace).
if
err
=
m
.
SetWorkspace
(
newCurrentWorkspace
);
err
!=
nil
{
return
err
}
m
.
Ui
.
Output
(
m
.
Colorize
()
.
Color
(
"[reset][bold]Migration complete! Your workspaces are as follows:[reset]"
))
var
out
bytes
.
Buffer
for
_
,
name
:=
range
workspaces
{
if
name
==
newCurrentWorkspace
{
out
.
WriteString
(
"* "
)
}
else
{
out
.
WriteString
(
" "
)
}
out
.
WriteString
(
name
+
"
\n
"
)
}
m
.
Ui
.
Output
(
out
.
String
())
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help