Skip to content

Commit 5320edc

Browse files
committed
WIP
1 parent bae76ed commit 5320edc

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

internal/command/state_migrate.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,67 @@ func (c *StateMigrateCommand) Run(rawArgs []string) int {
112112
return 1
113113
}
114114

115+
// func (c *StateMigrateCommand) srcBackendFromStateMigrationInstructions(root *configs.Module, locks *depsfile.Locks, viewType arguments.ViewType) (backendrun.OperationsBackend, tfdiags.Diagnostics) {
116+
// var diags tfdiags.Diagnostics
117+
118+
// sm := root.StateMigrationInstructions
119+
120+
// var opts *BackendOpts
121+
// switch {
122+
// case sm.Backend != nil:
123+
// opts = &BackendOpts{
124+
// BackendConfig: sm.Backend,
125+
// Locks: locks,
126+
// ViewType: viewType,
127+
// }
128+
// case sm.StateStore != nil:
129+
// // Annotate state_store config representation with info about how the provider
130+
// // is supplied to Terraform.
131+
// isReattached, err := reattach.IsProviderReattached(sm.StateStore.ProviderAddr, os.Getenv("TF_REATTACH_PROVIDERS"))
132+
// if err != nil {
133+
// panic(fmt.Sprintf("Unable to determine if provider %s is reattached while initializing the state store. This is a bug in Terraform and should be reported: %v", sm.StateStore.ProviderAddr.ForDisplay(), err))
134+
// }
135+
// sm.StateStore.ProviderSupplyMode = getproviders.DetermineProviderSupplyMode(c.Meta.isProviderDevOverride(sm.StateStore.ProviderAddr), isReattached, sm.StateStore.ProviderAddr.IsBuiltIn())
136+
137+
// // Check the provider for state storage is present, either via the dependency lock file or
138+
// // supplied via developer overrides, reattach config, or being built-in.
139+
// //
140+
// // Remember, the (Meta).backend method is used for non-init commands, so we expect dependency locks
141+
// // to be present or for the provider to be otherwise available, e.g. via reattach config.
142+
// depsDiags := sm.StateStore.VerifyDependencySelection(locks, root.ProviderRequirements, sm.StateStore.ProviderSupplyMode)
143+
// diags = diags.Append(depsDiags)
144+
// if depsDiags.HasErrors() {
145+
// return nil, diags
146+
// }
147+
148+
// opts = &BackendOpts{
149+
// StateStoreConfig: sm.StateStore,
150+
// Locks: locks,
151+
// ViewType: viewType,
152+
// }
153+
// default:
154+
// diags = diags.Append(tfdiags.Sourceless(
155+
// tfdiags.Error,
156+
// "Missing state migration configuration",
157+
// "One of 'backend' or 'state_store' blocks must be present in the state migration instructions.",
158+
// ))
159+
// return nil, diags
160+
// }
161+
162+
// // This method should not be used for init commands,
163+
// // so we always set this value as false.
164+
// opts.Init = false
165+
166+
// // Load the backend
167+
// be, beDiags := c.Meta.Backend(opts)
168+
// diags = diags.Append(beDiags)
169+
// if beDiags.HasErrors() {
170+
// return nil, diags
171+
// }
172+
173+
// return be, diags
174+
// }
175+
115176
func (c *StateMigrateCommand) Help() string {
116177
helpText := `
117178
Usage: terraform [global options] state migrate [options]

0 commit comments

Comments
 (0)