Skip to content

Plan creates with diffs, and apply the deletes of an emptied folder - #149

Merged
99-not-out merged 3 commits into
mainfrom
fix/plan-diffs-and-empty-folders
Oct 7, 2026
Merged

99-not-out merged 3 commits into
mainfrom
fix/plan-diffs-and-empty-folders

Conversation

@99-not-out

Copy link
Copy Markdown
Contributor

TL;DR: Dry runs that create something print diffs, and emptying a folder applies its deletes.

Stacked on #148.

What & why

Running apply -r --enable-state as a GitOps plan and apply turned up three smaller problems:

  • --print-diff failed for anything the Console did not have yet (could not find any matching resource), so no dry run that creates a resource could print diffs. A resource not found is now diffed against nothing.
  • An emptied folder skipped the state's deletes: No resources found to apply came first, so removing the last file never deleted what it described. With state enabled, the deletes now run first.
  • A result line followed a diff on the same line (the diff did not end with a newline), so tools reading the output line by line missed Topic/x: Created. It now starts its own line.

Changes

  • ErrResourceNotFound from the Console and Gateway clients' lookup; diff mode treats it as "nothing there yet".
  • Empty folder with state: the state's deletes run, then "No resources found to apply".
  • Diff output ends with a newline before the result line.

Notes

  • Behaviour change to weigh: with --enable-state, applying an empty folder now deletes everything the state manages for it. That is what removing the files means, but a mistakenly emptied folder now deletes too.
  • Checked against a local Console (main image): --print-diff on a new topic prints the diff and Created; an emptied folder deletes its topic.
  • make lint reports only the two existing unparam findings in cmd/template.go.

@99-not-out
99-not-out added this pull request to stack #150 October 6, 2026 16:12
@99-not-out
99-not-out marked this pull request as ready for review October 6, 2026 16:16
@99-not-out
99-not-out force-pushed the fix/plan-diffs-and-empty-folders branch 2 times, most recently from d78c38f to 7203de1 Compare October 7, 2026 08:57
Base automatically changed from fix/state-identity to main October 7, 2026 09:19
@99-not-out
99-not-out force-pushed the fix/plan-diffs-and-empty-folders branch from 7203de1 to d2d19c7 Compare October 7, 2026 09:20
99-not-out and others added 3 commits October 7, 2026 11:42
apply --print-diff fetched the current resource to diff against and
failed when there was none, so a dry run planning any create failed.
A resource not found is now diffed against nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B464sFQc8q6VkehfkByBaX
apply -r with state stopped at "No resources found to apply" before
working out the state's deletes, so removing the last file of a folder
never deleted what it described. With state enabled an empty folder now
deletes everything the state manages that is no longer there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B464sFQc8q6VkehfkByBaX
The diff printed by --print-diff did not end with a newline, so the
result line that followed ("Topic/x: Created") was glued to it and lost
to anything reading the output line by line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B464sFQc8q6VkehfkByBaX
@99-not-out
99-not-out force-pushed the fix/plan-diffs-and-empty-folders branch from d2d19c7 to c4436fe Compare October 7, 2026 10:42
@99-not-out
99-not-out merged commit 0983e74 into main Oct 7, 2026
7 checks passed
@99-not-out
99-not-out deleted the fix/plan-diffs-and-empty-folders branch October 7, 2026 10:58
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.

3 participants