mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
cloud: Add streamlined 'remote' backend state migration path
For Terraform Cloud users using the 'remote' backend, the existing 'pattern' prompt should work just fine - but because their workspaces are already present in TFC, the 'migration' here is really just realigning their local workspaces with Terraform Cloud. Instead of forcing users to do the mental gymnastics of what it means to migrate from 'prefix' - and because their remote workspaces probably already exist and already conform to Terraform Cloud's naming concerns - streamline the process for them and calculate the necessary pattern to migrate as-is, without any user intervention necessary.
This commit is contained in:
@@ -569,6 +569,17 @@ func (b *Remote) workspaces() ([]string, error) {
|
||||
return names, nil
|
||||
}
|
||||
|
||||
// WorkspaceNamePattern provides an appropriate workspace renaming pattern for backend migration
|
||||
// purposes (handled outside of this package), based on previous usage of this backend with the
|
||||
// 'prefix' workspace functionality. As of this writing, see meta_backend.migrate.go
|
||||
func (b *Remote) WorkspaceNamePattern() string {
|
||||
if b.prefix != "" {
|
||||
return b.prefix + "*"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// DeleteWorkspace implements backend.Enhanced.
|
||||
func (b *Remote) DeleteWorkspace(name string) error {
|
||||
if b.workspace == "" && name == backend.DefaultStateName {
|
||||
|
||||
Reference in New Issue
Block a user