fix: complete reset recovery safety
This commit is contained in:
+19
-3
@@ -197,7 +197,16 @@ func runMaintenanceCommand(args []string, input io.Reader, output io.Writer, sto
|
||||
if args[0] != "reset" {
|
||||
return errors.New("invalid maintenance command")
|
||||
}
|
||||
fmt.Fprint(output, "Reset every managed Target and restore recorded original state? [y/N] ")
|
||||
readOnlyState, readOnlyErr := store.ReadOnlyLoad()
|
||||
if readOnlyErr != nil {
|
||||
return fmt.Errorf("inspect Profile state before reset confirmation: %w", readOnlyErr)
|
||||
}
|
||||
warning := app.NewMaintenance(readOnlyState, targets, nil, nil).ResetConfirmation(context.Background())
|
||||
fmt.Fprintln(output, "Reset every managed Target and restore recorded original state?")
|
||||
if warning != "" {
|
||||
fmt.Fprintln(output, warning)
|
||||
}
|
||||
fmt.Fprint(output, "Continue? [y/N] ")
|
||||
answer, _ := bufio.NewReader(input).ReadString('\n')
|
||||
answer = strings.ToLower(strings.TrimSpace(answer))
|
||||
if answer != "y" && answer != "yes" {
|
||||
@@ -222,8 +231,15 @@ func runMaintenanceCommand(args []string, input io.Reader, output io.Writer, sto
|
||||
fmt.Fprintf(output, "%s: skipped (%s) — %s\n", item.TargetID, item.Inspection.State, profile.RedactText(item.Inspection.Evidence))
|
||||
continue
|
||||
}
|
||||
if item.Err != nil {
|
||||
fmt.Fprintf(output, "%s: failed (%s) — %s; fresh inspection: %s\n", item.TargetID, item.Inspection.State, profile.RedactText(item.Err.Error()), profile.RedactText(item.Inspection.Evidence))
|
||||
if item.OperationErr != nil {
|
||||
fmt.Fprintf(output, "%s: failed (%s) — %s; fresh inspection: %s\n", item.TargetID, item.Inspection.State, profile.RedactText(item.OperationErr.Error()), profile.RedactText(item.Inspection.Evidence))
|
||||
if item.LogErr != nil {
|
||||
fmt.Fprintf(output, "%s: operation logging also failed — %s\n", item.TargetID, profile.RedactText(item.LogErr.Error()))
|
||||
}
|
||||
continue
|
||||
}
|
||||
if item.LogErr != nil {
|
||||
fmt.Fprintf(output, "%s: reset (%s) — %s; operation logging failed — %s\n", item.TargetID, item.Inspection.State, profile.RedactText(item.Inspection.Evidence), profile.RedactText(item.LogErr.Error()))
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(output, "%s: reset (%s) — %s\n", item.TargetID, item.Inspection.State, profile.RedactText(item.Inspection.Evidence))
|
||||
|
||||
Reference in New Issue
Block a user