Skip to content

Support report/fleet as spec "kinds"#40586

Merged
sgress454 merged 3 commits intomainfrom
sgress454/alias-fleetctl-spec-kinds
Feb 26, 2026
Merged

Support report/fleet as spec "kinds"#40586
sgress454 merged 3 commits intomainfrom
sgress454/alias-fleetctl-spec-kinds

Conversation

@sgress454
Copy link
Copy Markdown
Contributor

@sgress454 sgress454 commented Feb 26, 2026

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 for more information.
    n/a

Testing

  • Added/updated automated tests
  • 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

@sgress454
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 26, 2026

Walkthrough

This 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description provides the related issues, high-level details of the change, and addresses most checklist items, though several sections are incomplete or marked n/a. Expand the description with specific details about implementation approach, why this change is necessary, and complete the manual testing checklist to verify all four spec kinds work correctly with deprecation warnings.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Support report/fleet as spec "kinds"' accurately summarizes the main change: adding support for new 'report' and 'fleet' as specification kinds throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sgress454/alias-fleetctl-spec-kinds

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Document the breaking change from kind: query to kind: report in YAML output.

WriteQueriesToYaml now emits kind: report instead of kind: 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 for kind: query will 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 | 🟡 Minor

Breaking change: Query spec output now uses kind: report instead of kind: query.

This changes the serialized output format for queries returned by fleetctl get queries --yaml and fleetctl get queries --json. Any scripts, CI pipelines, or tooling that parse this output and filter by kind: query will need to be updated to handle kind: report.

The fleetctl tool accepts both kind: query and kind: report when 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.go
  • cmd/fleetctl/fleetctl/get.go
  • cmd/fleetctl/fleetctl/get_test.go
  • cmd/fleetctl/fleetctl/testdata/convert_output.yml
  • cmd/fleetctl/fleetctl/testdata/expectedGetTeamsJson.json
  • cmd/fleetctl/fleetctl/testdata/expectedGetTeamsYaml.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Empty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1And2Set.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Empty.yml
  • cmd/fleetctl/fleetctl/testdata/macosSetupExpectedTeam1Set.yml
  • cmd/fleetctl/fleetctl/upgrade_packs.go
  • cmd/fleetctl/fleetctl/upgrade_packs_test.go
  • pkg/spec/spec.go
  • server/fleet/queries.go
  • server/fleet/teams.go

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 26, 2026

Codecov Report

❌ Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.28%. Comparing base (baf7f82) to head (5636515).
⚠️ Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
pkg/spec/spec.go 33.33% 2 Missing and 2 partials ⚠️
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           
Flag Coverage Δ
backend 68.17% <63.63%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sgress454 sgress454 force-pushed the sgress454/alias-fleetctl-spec-kinds branch from a0517b9 to ba16ffe Compare February 26, 2026 16:49
@sgress454 sgress454 changed the title WIP: support report/fleet as spec "kinds" Support report/fleet as spec "kinds" Feb 26, 2026
@sgress454 sgress454 marked this pull request as ready for review February 26, 2026 17:34
@sgress454 sgress454 requested a review from a team as a code owner February 26, 2026 17:34
@sgress454 sgress454 merged commit 55b65e2 into main Feb 26, 2026
51 checks passed
@sgress454 sgress454 deleted the sgress454/alias-fleetctl-spec-kinds branch February 26, 2026 19:07
sgress454 added a commit that referenced this pull request Feb 26, 2026
<!-- 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
sgress454 added a commit that referenced this pull request Feb 26, 2026
Cherry-pick of #40586 into `rc-minor-fleet-v4.82.0`.
@georgekarrv georgekarrv mentioned this pull request Mar 3, 2026
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.

2 participants