command/meta_backend_migrate:Tweak multi-to-single To TFC copy
This commit is contained in:
parent
dfb4609be2
commit
09d5b70b7a
|
@ -577,10 +577,6 @@ func (m *Meta) backendMigrateTFC(opts *backendMigrateOpts) error {
|
||||||
|
|
||||||
multiSource := !sourceSingleState && len(sourceWorkspaces) > 1
|
multiSource := !sourceSingleState && len(sourceWorkspaces) > 1
|
||||||
if multiSource && destinationNameStrategy {
|
if multiSource && destinationNameStrategy {
|
||||||
if err := m.promptMultiToSingleCloudMigration(opts); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
currentWorkspace, err := m.Workspace()
|
currentWorkspace, err := m.Workspace()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -588,6 +584,10 @@ func (m *Meta) backendMigrateTFC(opts *backendMigrateOpts) error {
|
||||||
|
|
||||||
opts.sourceWorkspace = currentWorkspace
|
opts.sourceWorkspace = currentWorkspace
|
||||||
opts.destinationWorkspace = cloudBackendDestination.WorkspaceMapping.Name
|
opts.destinationWorkspace = cloudBackendDestination.WorkspaceMapping.Name
|
||||||
|
if err := m.promptMultiToSingleCloudMigration(opts); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] backendMigrateTFC: multi-to-single migration from source %s to destination %q", opts.sourceWorkspace, opts.destinationWorkspace)
|
log.Printf("[INFO] backendMigrateTFC: multi-to-single migration from source %s to destination %q", opts.sourceWorkspace, opts.destinationWorkspace)
|
||||||
|
|
||||||
return m.backendMigrateState_s_s(opts)
|
return m.backendMigrateState_s_s(opts)
|
||||||
|
@ -670,9 +670,11 @@ func (m *Meta) promptMultiToSingleCloudMigration(opts *backendMigrateOpts) error
|
||||||
var err error
|
var err error
|
||||||
// Ask the user if they want to migrate their existing remote state
|
// Ask the user if they want to migrate their existing remote state
|
||||||
migrate, err = m.confirm(&terraform.InputOpts{
|
migrate, err = m.confirm(&terraform.InputOpts{
|
||||||
Id: "backend-migrate-multistate-to-single",
|
Id: "backend-migrate-multistate-to-single",
|
||||||
Query: "Do you want to copy only your current workspace?",
|
Query: "Do you want to copy only your current workspace?",
|
||||||
Description: strings.TrimSpace(tfcInputBackendMigrateMultiToSingle),
|
Description: fmt.Sprintf(
|
||||||
|
strings.TrimSpace(tfcInputBackendMigrateMultiToSingle),
|
||||||
|
opts.SourceType, opts.destinationWorkspace),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error asking for state migration action: %s", err)
|
return fmt.Errorf("Error asking for state migration action: %s", err)
|
||||||
|
@ -820,8 +822,11 @@ For more information on workspace naming, see https://www.terraform.io/docs/clou
|
||||||
`
|
`
|
||||||
|
|
||||||
const tfcInputBackendMigrateMultiToSingle = `
|
const tfcInputBackendMigrateMultiToSingle = `
|
||||||
The cloud configuration has one workspace declared, and you are attemtping to migrate multiple workspaces
|
The previous backend %[1]q has multiple workspaces, but Terraform Cloud has been
|
||||||
to a single workspace. By continuing, you will only migrate your current workspace.
|
configured to use a single workspace (%[2]q). By continuing, you will only
|
||||||
|
migrate your current workspace. If you wish to migrate all workspaces from the
|
||||||
|
previous backend, use the 'tags' strategy in your workspace configuration block
|
||||||
|
instead.
|
||||||
`
|
`
|
||||||
|
|
||||||
const inputBackendMigrateEmpty = `
|
const inputBackendMigrateEmpty = `
|
||||||
|
|
Loading…
Reference in New Issue