Gate all policy label inclusions/exclusions as premium-only - #47686
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aligns policy label-scoping behavior with the docs by making all policy label inclusion/exclusion fields (labels_include_any, labels_include_all, labels_exclude_any, labels_exclude_all) Fleet Premium-only across API endpoints, service-layer policy creation/modification/spec apply, and fleetctl GitOps workflows.
Changes:
- Gate
labels_include_anyandlabels_exclude_anyas Premium-only alongside the existing*_include_all/*_exclude_allgates in global/team policy creation, modification, and spec application. - Mark
labels_include_any/labels_exclude_anyrequest fields aspremium:"true"in API request structs andModifyPolicyPayload. - Update
fleetctlGitOps validation and generation to treat policy label scoping as Premium-only.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| server/service/team_policies.go | Extends Premium gating for team policy create/modify to include *_include_any and *_exclude_any. |
| server/service/global_policies.go | Extends Premium gating for global policy create + policy spec apply to include *_include_any and *_exclude_any. |
| server/service/global_policies_test.go | Adjusts a unit test to run under Premium so label validation still executes after the new gate. |
| server/fleet/policies.go | Marks ModifyPolicyPayload’s labels_include_any/labels_exclude_any as premium-only. |
| server/fleet/api_policies.go | Marks GlobalPolicyRequest and TeamPolicyRequest labels_include_any/labels_exclude_any as premium-only. |
| cmd/fleetctl/fleetctl/gitops.go | Adds free-tier GitOps validation errors for policy labels_include_any/labels_exclude_any. |
| cmd/fleetctl/fleetctl/generate_gitops.go | Stops emitting policy labels_include_any/labels_exclude_any in generated GitOps output unless Premium. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
WalkthroughThis PR extends the premium-only license gating to cover Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #47686 +/- ##
==========================================
+ Coverage 67.18% 67.19% +0.01%
==========================================
Files 3629 3630 +1
Lines 229302 229468 +166
Branches 11948 11948
==========================================
+ Hits 154060 154195 +135
- Misses 61387 61410 +23
- Partials 13855 13863 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| } | ||
| // Parse any labels. | ||
| if policy.LabelsIncludeAny != nil { | ||
| if policy.LabelsIncludeAny != nil && cmd.AppConfig.License.IsPremium() { |
There was a problem hiding this comment.
nit: Refactor this so that the cmd.AppConfig.License.IsPremium() check is at the top:
if cmd.AppConfig.License.IsPremium() {
if policy.LabelsIncludeAny != nil {
...
Related issue: Resolves #47677
Updating code so that it matches the docs (all label inclusions and exclusions for policies should be premium-only):
labels_include_anydocumentation #47643Testing
Summary by CodeRabbit
Bug Fixes
labels_include_anyandlabels_exclude_any(in addition to existingany/allrestrictions).labels_include_any/labels_exclude_anyon non-premium instances.Tests