Skip to content

feat: keep compose edits on Apply with a 3-way merge - #112

Merged
jackspiering merged 2 commits into
mainfrom
feat/keep-compose-edits-on-apply
Nov 6, 2026
Merged

jackspiering merged 2 commits into
mainfrom
feat/keep-compose-edits-on-apply

Conversation

@jackspiering

Copy link
Copy Markdown
Owner

Summary

Brings the behavior of the ScaleTail stack update script (tailscale-dev/ScaleTail#404, still open) into Tailarr. Before this change, Apply
overwrote the deployed compose file, and the README told operators to copy their edits to a safe place first.

Mapping of ScaleTail #404 to Tailarr

Ported:

  • 3-way merge with git merge-file: your file, the saved upstream copy, the new upstream file. Deploy and Apply save the catalog compose
    file as .tailarr.compose.base.yaml. Git runs with the hardened setup (own process group, timeout, interrupt context, filtered env) and
    without user or system git config.
  • First update without a saved copy: replace the file, say whether settings or only comments differ, and name the backup that holds the
    old file.
  • New .env keys come with the template comment lines above them.
  • Names only, never values or file contents, in the output.

Already in Tailarr:

  • Backup before any write (Apply snapshot), ## Upgrading notes, the list of new .env keys, and validation by pull and up with
    rollback.

Different on purpose:

  • A conflict refuses Apply before any write. Tailarr runs compose up right after the merge, so it never writes conflict markers. The error
    says how to get past it: undo the edit in those lines, or delete the base file to take the catalog file.
  • A catalog SERVICE rename keeps the deployed value (MergeEnv keeps a local non-empty value), so no --force is needed. A test covers it.
  • The catalog clone replaces the archive download.
  • Not ported: skipping a key that the deployed .env has only commented out. All 135 catalog templates ship commented-out keys, so that rule
    would block the catalog from ever turning one on. A test guards this.

Safety

  • The base is part of the Apply snapshot. A failed Apply rolls it back, so the next Apply still sees the catalog change
    (TestApplyFailureRollsBackComposeBase).
  • The compose file is still written in place, so its inode survives. Mode-only template changes still apply.
  • The preview shows the diff to the merged result and labels the file merged, replaced, conflict, or mode. It also names deployed
    .env keys that the template does not have.

Verification

  • go test -race ./... and go test -race -tags integration ./... (live Docker 29.9.1): pass.
  • go vet, gofmt -l, golangci-lint run (0 issues), rumdl check ., go mod tidy diff: clean.
  • govulncheck ./... with GOTOOLCHAIN=go1.27.3 (the CI GO_VERSION): no vulnerabilities. The local 1.27.1 toolchain reports two
    stdlib CVEs that 1.27.3 fixes.
  • No new Go dependency. version.go is not changed.

Apply used to overwrite the deployed compose file, so an operator lost
every edit. This ports the behavior of the ScaleTail stack update script
(tailscale-dev/ScaleTail#404) into Tailarr.

- Deploy and Apply record the catalog compose file as
  .tailarr.compose.base.yaml. Apply merges the catalog change into the
  deployed file with git merge-file, run with the hardened git setup and
  without user or system git config.
- A conflict refuses Apply before any write and never writes conflict
  markers. The error says how to get past it.
- A deployment without a base (older Tailarr) gets the catalog file once,
  and the output names the backup that holds the old file and says
  whether settings or only comments differed.
- The base is part of the Apply snapshot, so a failed Apply rolls it back
  and the next Apply still sees the catalog change.
- The compose file is still written in place, so its inode survives.
- The preview shows the diff to the merged result, labels the file as
  merged, replaced, or conflict, and names .env keys the catalog dropped.
- New .env keys bring the template comment lines above them. A key the
  operator commented out is not added again.
Every ScaleTail template ships optional keys as commented-out lines, so
skipping a key that the deployed .env has only commented out would block
the catalog from ever turning one on. Drop that rule and keep the template
comments for new keys. Make the first-Apply notice and the preview note
conditional on the operator having edited the file.
@jackspiering
jackspiering enabled auto-merge (squash) November 6, 2026 18:14
@jackspiering
jackspiering merged commit 3388b11 into main Nov 6, 2026
8 checks passed
@jackspiering
jackspiering deleted the feat/keep-compose-edits-on-apply branch November 6, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant