Skip to content

Commit 5ec4e98

Browse files
committed
fix(init): stop promising an interactive diff on preset update
The preset drift warning and the upgrading guide said that `talm init --update` shows a diff of the new preset against the project's templates and keeps the operator's edits. It does neither: each differing preset file gets an `Overwrite? [y/N]` prompt with no diff, and accepting replaces the file whole. The warning now says that, and tells the operator to decline edited files and merge them by hand. The guide describes the prompt, the whole-file replace, `--force`, and that the baseline advances even when every file is declined. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent c8e651d commit 5ec4e98

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎docs/manual-test-plan.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ talm init --update --preset <your-preset> --force
330330
talm template -f nodes/node0.yaml --offline 2>&1 >/dev/null | grep '^WARN:.*preset' && echo "FAIL: preset drift not cleared" || echo "OK: preset drift cleared"
331331
```
332332

333-
`init --update` rewrites `.talm-preset.lock` to the current baseline, so the warning clears even if you declined individual preset-file diffs. Expected: `OK: preset drift cleared`. Note: `--force` auto-accepts every preset-file diff, overwriting the operator edit made earlier in this scenario — the "edits are preserved via the interactive diff" promise holds only without `--force`; this test stand is disposable, a real project should run the clear step interactively.
333+
`init --update` rewrites `.talm-preset.lock` to the current baseline, so the warning clears even if you declined individual preset-file diffs. Expected: `OK: preset drift cleared`. Note: `--force` accepts every preset file without asking, overwriting the operator edit made earlier in this scenario. Without `--force`, `init --update` asks `Overwrite? [y/N]` per file and shows no diff, so a real project declines its edited files and merges them by hand; this test stand is disposable.
334334

335335
Regression anchors: `TestPresetLock_RoundTrip_NoDrift`, `TestCheckPresetDrift_StaleBaseline_Drift`, `TestCheckPresetDrift_OperatorEditedTemplates_NoDrift` (the false-positive guard), `TestCheckPresetDrift_NoLock_NoBaselineSentinel`, and `TestEvaluatePresetDrift` pin every branch above.
336336

‎docs/operations/upgrading.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ presetHash: <hash of the preset built into the binary at init time>
6868
A release build then compares the binary's *current* preset hash against that pinned baseline — never against your edited `templates/` — so operator customizations are never reported as drift. When a newer binary ships changed preset defaults, the baseline no longer matches and talm warns:
6969

7070
```text
71-
WARN: project's cozystack preset differs from the copy built into talm <version>; run `talm init --update --preset cozystack` to pull the new preset defaults (your templates/ edits are preserved via the interactive diff)
71+
WARN: project's cozystack preset differs from the copy built into talm <version>; run `talm init --update --preset cozystack` to pull the new preset defaults; it asks before it overwrites each preset file whole, so decline the files you have edited and merge their changes by hand
7272
```
7373

74-
`talm init --update --preset <preset>` shows you an interactive diff of the new preset against your `templates/`, lets you merge what you want, and advances the baseline — which clears the warning even if you decline individual diffs to keep your customizations. `--strict-charts` / `strictCharts: true` escalate this to a hard error exactly as for the library. Projects with no `.talm-preset.lock` (generated before preset pinning) stay silent — there is no baseline to compare — unless strict mode is on, which treats a missing baseline as a blocker. Commit `.talm-preset.lock` so the baseline is shared across your team.
74+
`talm init --update --preset <preset>` asks `File <path> differs from template. Overwrite? [y/N]` for each preset file that differs, shows no diff, and replaces the file whole when you accept. Decline the files you have edited, compare them with the preset by hand (the preset is in `charts/<preset>/` of the talm source at the binary's version), and merge what you want. The run advances the baseline either way, which clears the warning even if you decline every file. `--force` accepts every file without asking. `--strict-charts` / `strictCharts: true` escalate this to a hard error exactly as for the library. Projects with no `.talm-preset.lock` (generated before preset pinning) stay silent — there is no baseline to compare — unless strict mode is on, which treats a missing baseline as a blocker. Commit `.talm-preset.lock` so the baseline is shared across your team.

‎pkg/commands/chart_drift.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ func CheckPresetDrift(rootDir, binaryVersion string) (bool, string, error) {
310310

311311
return true, fmt.Sprintf(
312312
"project's %s preset differs from the copy built into talm %s; "+
313-
"run `talm init --update --preset %s` to pull the new preset defaults (your templates/ edits are preserved via the interactive diff)",
313+
"run `talm init --update --preset %s` to pull the new preset defaults; it asks before it overwrites each "+
314+
"preset file whole, so decline the files you have edited and merge their changes by hand",
314315
lock.Preset, binaryVersion, lock.Preset,
315316
), nil
316317
}

‎pkg/commands/chart_drift_test.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,14 @@ func TestCheckPresetDrift_StaleBaseline_Drift(t *testing.T) {
304304
if !strings.Contains(msg, "talm init --update --preset cozystack") {
305305
t.Errorf("drift message must point at `talm init --update --preset cozystack`; got %q", msg)
306306
}
307+
// init --update asks to overwrite each preset file whole and shows no
308+
// diff, so the message must not promise that edits survive a merge.
309+
if strings.Contains(msg, "interactive diff") || strings.Contains(msg, "preserved") {
310+
t.Errorf("drift message promises a merge init --update does not do; got %q", msg)
311+
}
312+
if !strings.Contains(msg, "overwrite") {
313+
t.Errorf("drift message must say init --update offers to overwrite files; got %q", msg)
314+
}
307315
}
308316

309317
// TestCheckPresetDrift_NoLock_NoBaselineSentinel pins the missing-baseline

0 commit comments

Comments
 (0)