Add GitOps for policy labels
For #27301
Checklist for submitter
- [X] Changes file added for user-visible changes in
changes/,orbit/changes/oree/fleetd-chrome/changes. See Changes files for more information. - [X] Input data is properly validated,
SELECT *is avoided, SQL injection is prevented (using placeholders for values in statements) - [X] Added/updated automated tests
- [X] A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it)
- [X] Manual QA for all new/changed functionality
Details
This PR adds the ability to set/unset labels on policies via GitOps. It builds on https://github.com/fleetdm/fleet/pull/27575 (back end for policy labels) and updates the PolicySpec type and ApplyPolicySpecs methods to update the policy_labels table where needed.
Testing
- Create a few labels in the UI
- Create a global policy "foo" in the UI without labels
- Create a global policy "bar" in the UI with labels
- Create a global policy "baz" in the UI with labels
- Use
fleetctl gitopswith a global .yml file, and underpolicies:add "foo", "bar", "baz" and "boop".
- Add labels to "foo" with
labels_include_any: - Don't add
labels_include_any:to "bar" - Add labels to "baz" with
labels_include_any:, but different labels than what you added in the UI - Add labels to "boop" with
labels_include_any:
The expected outcome when viewing the queries in the UI (on the "edit query" screen)
- Foo, Baz and Boop should have the labels specified in gitops
- Bar should have no labels
Repeat testing with excluded labels.
Codecov Report
Attention: Patch coverage is 81.10236% with 24 lines in your changes missing coverage. Please review.
Project coverage is 63.27%. Comparing base (
b7c547b) to head (d1cbf13). Report is 23 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #27781 +/- ##
==========================================
- Coverage 63.41% 63.27% -0.15%
==========================================
Files 1765 1765
Lines 168342 169009 +667
Branches 4845 4866 +21
==========================================
+ Hits 106758 106941 +183
- Misses 53258 53719 +461
- Partials 8326 8349 +23
| Flag | Coverage Δ | |
|---|---|---|
| backend | 64.33% <81.10%> (-0.09%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
The submitter checklist seems to be missing 😮