Implement restore planning for the restore subcommand
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
var newObjectStoreFromConfigFn = storage.NewObjectStoreFromConfig
|
||||
var discoverRemoteCurrentStateFn = discoverRemoteCurrentState
|
||||
var buildRestorePlanFn = buildRestorePlan
|
||||
|
||||
// Restore validates restore CLI/config inputs and storage preflight for future restore phases.
|
||||
func Restore(ctx context.Context, args []string, out io.Writer) error {
|
||||
@@ -74,13 +75,32 @@ func Restore(ctx context.Context, args []string, out io.Writer) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
|
||||
// Phase 3 boundary: discovery is implemented; planning/execution is deferred.
|
||||
_ = dryRun
|
||||
_ = force
|
||||
_ = includeAudio
|
||||
plan, err := buildRestorePlanFn(ctx, cfg, current, objectStore, RestorePlanOptions{
|
||||
IncludeAudio: includeAudio,
|
||||
Force: force,
|
||||
DryRun: dryRun,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
if err := writeRestorePlan(out, current, plan, RestorePlanOptions{
|
||||
IncludeAudio: includeAudio,
|
||||
Force: force,
|
||||
DryRun: dryRun,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("restore: write plan output: %w", err)
|
||||
}
|
||||
if dryRun {
|
||||
return nil
|
||||
}
|
||||
if plan.ConflictCount > 0 && !force {
|
||||
return fmt.Errorf(
|
||||
"restore: plan has %d conflicting path(s); rerun with --force or resolve local conflicts",
|
||||
plan.ConflictCount,
|
||||
)
|
||||
}
|
||||
return fmt.Errorf(
|
||||
"restore: discovered remote current state for %s/%s (run %s); not yet implemented (phase 3: remote current-state discovery)",
|
||||
"restore: planned remote restore for %s/%s (run %s); not yet implemented (phase 4: restore execution)",
|
||||
current.Campaign,
|
||||
current.SessionID,
|
||||
current.RunID,
|
||||
|
||||
Reference in New Issue
Block a user