Support report/fleet as spec "kinds"#40586
Conversation
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThis pull request systematically changes Kind metadata values for emitted specifications across the fleetctl codebase. Queries are now emitted with Kind set to "report" instead of "query", while teams are emitted with Kind set to "fleet" instead of "team". New public constants ReportKind and FleetKind are introduced. Changes propagate through conversion logic, output serialization, and YAML/JSON marshaling functions. Test fixtures and test expectations are updated throughout to reflect the new Kind values in output payloads. 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
server/fleet/queries.go (1)
408-418:⚠️ Potential issue | 🟠 MajorDocument the breaking change from
kind: querytokind: reportin YAML output.
WriteQueriesToYamlnow emitskind: reportinstead ofkind: query. While the parsing side (pkg/spec/spec.go) accepts both values as input, any external tools or automation that consume this YAML output and explicitly check forkind: querywill break. No migration or release notes appear to exist for this change. Consider adding a warning to the release notes or migration guide alerting users to this breaking change in the output format.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/fleet/queries.go` around lines 408 - 418, Update the project documentation and release notes to call out the breaking change where WriteQueriesToYaml now emits ObjectMetadata.Kind as ReportKind (previously "query") in the YAML produced by QueryObject (see QueryObject, ObjectMetadata, ApiVersion, ReportKind in server/fleet/queries.go) and note that pkg/spec/spec.go accepts both "query" and "report" on input; document the change, provide migration guidance for external tools that expect kind: query, and add a short warning entry to the release notes and migration guide so consumers are aware of the new output format.cmd/fleetctl/fleetctl/get.go (1)
105-113:⚠️ Potential issue | 🟡 MinorBreaking change: Query spec output now uses
kind: reportinstead ofkind: query.This changes the serialized output format for queries returned by
fleetctl get queries --yamlandfleetctl get queries --json. Any scripts, CI pipelines, or tooling that parse this output and filter bykind: querywill need to be updated to handlekind: report.The fleetctl tool accepts both
kind: queryandkind: reportwhen importing YAML files, so existing YAML files remain compatible. A migration tool (tools/gitops-migrate) is available to automatically convert existing GitOps YAML files to the new format.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/fleetctl/fleetctl/get.go` around lines 105 - 113, The output for queries is currently hardcoded to use fleet.ReportKind in printQuerySpec, causing YAML/JSON to emit "kind: report" and breaking existing consumers; update printQuerySpec so specGeneric.Kind is set to the original query kind (fleet.QueryKind) instead of fleet.ReportKind (i.e., change the Kind assignment in the printQuerySpec function to fleet.QueryKind) so get queries output remains "kind: query".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@cmd/fleetctl/fleetctl/get.go`:
- Around line 105-113: The output for queries is currently hardcoded to use
fleet.ReportKind in printQuerySpec, causing YAML/JSON to emit "kind: report" and
breaking existing consumers; update printQuerySpec so specGeneric.Kind is set to
the original query kind (fleet.QueryKind) instead of fleet.ReportKind (i.e.,
change the Kind assignment in the printQuerySpec function to fleet.QueryKind) so
get queries output remains "kind: query".
In `@server/fleet/queries.go`:
- Around line 408-418: Update the project documentation and release notes to
call out the breaking change where WriteQueriesToYaml now emits
ObjectMetadata.Kind as ReportKind (previously "query") in the YAML produced by
QueryObject (see QueryObject, ObjectMetadata, ApiVersion, ReportKind in
server/fleet/queries.go) and note that pkg/spec/spec.go accepts both "query" and
"report" on input; document the change, provide migration guidance for external
tools that expect kind: query, and add a short warning entry to the release
notes and migration guide so consumers are aware of the new output format.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 10c997b and a0517b9ec092a20b0eca16a77fb7f057d918a0b3.
📒 Files selected for processing (15)
cmd/fleetctl/fleetctl/convert.gocmd/fleetctl/fleetctl/get.gocmd/fleetctl/fleetctl/get_test.gocmd/fleetctl/fleetctl/testdata/convert_output.ymlcmd/fleetctl/fleetctl/testdata/expectedGetTeamsJson.jsoncmd/fleetctl/fleetctl/testdata/expectedGetTeamsYaml.ymlcmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Empty.ymlcmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Set.ymlcmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Empty.ymlcmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Set.ymlcmd/fleetctl/fleetctl/upgrade_packs.gocmd/fleetctl/fleetctl/upgrade_packs_test.gopkg/spec/spec.goserver/fleet/queries.goserver/fleet/teams.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #40586 +/- ##
=======================================
Coverage 66.28% 66.28%
=======================================
Files 2466 2466
Lines 197552 197556 +4
Branches 8726 8726
=======================================
+ Hits 130946 130950 +4
Misses 54757 54757
Partials 11849 11849
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a0517b9 to
ba16ffe
Compare
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** For #39314 **Related issue:** For #39238 # Details This PR allows the use of "fleet" and "report" as spec "kinds", deprecating the use of "team" and "query". # Checklist for submitter If some of the following don't apply, delete the relevant line. - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. n/a ## Testing - [X] Added/updated automated tests - [X] QA'd all new/changed functionality manually Deprecation logs assume `--enable-log-topics=deprecated-field-names` is used in the command - [ ] `fleetctl apply -f /path/to/spec` should add/update a fleet when used with a spec containing `kind: fleet` - [ ] `fleetctl apply -f /path/to/spec` should add/update a report when used with a spec containing `kind: report` - [ ] `fleetctl apply -f /path/to/spec` should add/update a fleet when used with a spec containing `kind: team`, and log a deprecation warning - [ ] `fleetctl apply -f /path/to/spec` should add/update a report when used with a spec containing `kind: query`, , and log a deprecation warning
Cherry-pick of #40586 into `rc-minor-fleet-v4.82.0`.
Related issue: For #39314
Related issue: For #39238
Details
This PR allows the use of "fleet" and "report" as spec "kinds", deprecating the use of "team" and "query".
Checklist for submitter
If some of the following don't apply, delete the relevant line.
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
n/a
Testing
Deprecation logs assume
--enable-log-topics=deprecated-field-namesis used in the commandfleetctl apply -f /path/to/specshould add/update a fleet when used with a spec containingkind: fleetfleetctl apply -f /path/to/specshould add/update a report when used with a spec containingkind: reportfleetctl apply -f /path/to/specshould add/update a fleet when used with a spec containingkind: team, and log a deprecation warningfleetctl apply -f /path/to/specshould add/update a report when used with a spec containingkind: query, , and log a deprecation warning