Skip to content

feat: Add categories to fleet-plan diff output#36

Open
kc9wwh wants to merge 1 commit into
TsekNet:mainfrom
kc9wwh:main
Open

feat: Add categories to fleet-plan diff output#36
kc9wwh wants to merge 1 commit into
TsekNet:mainfrom
kc9wwh:main

Conversation

@kc9wwh
Copy link
Copy Markdown
Contributor

@kc9wwh kc9wwh commented May 1, 2026

Summary

  • Surface the categories field for all three software types (packages, fleet-maintained apps, app store apps) across all output formats (terminal, markdown, JSON)
  • Categories are compared as sets — reorder-only changes produce no diff
  • JSON output renders categories as []string arrays ({"old": null, "new": ["Communication"]}) while string fields remain strings

Changes

Parser (internal/parser/parser.go): Added Categories []string to parsed and raw software structs; wired through resolution functions with team-level override support (same pattern as self_service).

API client (internal/api/client.go): Added Categories []string to TeamSoftwarePackage, TeamFleetApp, TeamAppStoreApp.

Diff engine (internal/diff/differ.go): Added IsSlice/OldSlice/NewSlice fields to FieldDiff for structured JSON output. Added categoriesEqual (set comparison), formatCategories, sortedCategories helpers. Emit category diffs for
all software types in both ADDED and MODIFIED paths.

JSON renderer (internal/output/json.go): Changed JSONField.Old/New from string to any so slice fields render as arrays instead of stringified brackets.

Terminal/Markdown renderers: No code changes needed — formatCategories produces display strings like [Browsers, Communication] that the existing renderers handle naturally.

Validated output

~ fleet app snagit/darwin
    categories: "[]" → "[Productivity]"
~ fleet app spotify/darwin
    categories: "[]" → "[Communication]"
~ fleet app zed/darwin
    categories: "[]" → "[Developer tools]"

| MODIFIED | Workstations (canary) | Software | **fleet app snagit/darwin** | `categories`: `[]` → `[Productivity]` |

Test plan

  • go test -race ./... — all pass
  • go vet ./... — clean
  • Coverage ≥ 75% on all packages (diff: 78.5%, output: 90.2%, parser: 78.2%)
  • New unit tests: TestDiffSoftwareCategories (8 cases), TestCategoriesEqual, TestFormatCategories
  • New output tests: TestRenderDiffJSONCategories, TestRenderDiffJSONStringFieldsUnchanged, TestRenderDiffTerminalCategories, TestRenderDiffMarkdownCategories
  • Integration test updated: TestDiffTestdataAgainstMockAPI covers categories in mock state
  • Manual validation against live Fleet instance — terminal and markdown output confirmed

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