func Import(f *statefile.File, mgr Transient, force bool) error {
	if mgrM, ok := mgr.(Migrator); ok {
		return mgrM.WriteStateForMigration(f, force)
	}
	return mgr.WriteState(f.State)
}
Import loads the given state snapshot into the given manager, preserving
its metadata (serial and lineage) if the target manager supports metadata.

A state manager must implement the optional interface Migrator to get
access to the full metadata.

Unless "force" is true, Import will check first that the metadata given
in the file matches the current snapshot metadata for the manager, if the
manager supports metadata. Some managers do not support forcing, so a
write with an unsuitable lineage or serial may still be rejected even if
"force" is set. "force" has no effect for managers that do not support
snapshot metadata.

For state managers that also implement Persistent, it is the caller's
responsibility to persist the newly-written state after a successful result,
just as with calls to Writer.WriteState.

This function doesn't do any locking of its own, so if the state manager
also implements Locker the caller should hold a lock on it for the
duration of this call.
package statemgr
import (
	"fmt"
	"github.com/camptocamp/terraboard/internal/terraform/states/statefile"
)
type Migrator interface {
	PersistentMeta
	StateForMigration() *statefile.File
	WriteStateForMigration(f *statefile.File, force bool) error
}
func Migrate(dst, src Transient) error {
	if dstM, ok := dst.(Migrator); ok {
		if srcM, ok := src.(Migrator); ok {
			s := srcM.StateForMigration()
			return dstM.WriteStateForMigration(s, true)
		}
	}
	s := src.State()
	return dst.WriteState(s)
}