fleet/server
Scott Gress fca1e1ab42
Add GitOps for policy labels (#27781)
For #27301 

# Checklist for submitter

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [X] 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/Committing-Changes.md#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

1. Create a few labels in the UI
1. Create a global policy "foo" in the UI without labels
2. Create a global policy "bar" in the UI with labels
2. Create a global policy "baz" in the UI with labels
4. Use `fleetctl gitops` with a global .yml file, and under `policies:`
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.

---------

Co-authored-by: dantecatalfamo <dante.catalfamo@gmail.com>
Co-authored-by: Dante Catalfamo <43040593+dantecatalfamo@users.noreply.github.com>
2025-04-04 09:46:51 -05:00
..
archtest Basic Android MDM on/off functionality (#26309) 2025-02-18 09:43:11 -06:00
authz Cancel upcoming activities: DB schema and backend (#27710) 2025-04-01 14:08:56 -04:00
bindata
config Add Secureframe partnership override env var for transparency URL (#27388) 2025-03-31 14:43:17 -05:00
contexts Update to Go 1.24.1 (#27506) 2025-03-31 11:14:09 -05:00
cron Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
datastore Add GitOps for policy labels (#27781) 2025-04-04 09:46:51 -05:00
docs Added Android activity and better handling of deleted users. (#26640) 2025-02-27 14:19:15 -06:00
errorstore Adding telemetry for specific Fleet Desktop errors (#23349) 2024-10-31 14:24:42 -05:00
fleet Add GitOps for policy labels (#27781) 2025-04-04 09:46:51 -05:00
goose Add gosimple linter (#23250) 2024-10-29 14:17:51 -05:00
health 🧹 friday cleanup party: substitute deprecated import of go-kit (#19774) 2024-06-17 10:27:31 -03:00
launcher Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
live_query Fix flakey livequery test (#21666) 2024-08-29 10:03:45 -06:00
logging Add gosimple linter (#23250) 2024-10-29 14:17:51 -05:00
mail Utilize custom SMTP domain if set (#25669) 2025-01-28 11:10:52 -05:00
mdm Add more test coverage for Fleet-maintained apps (#27722) 2025-04-03 09:18:27 -05:00
mock Add SCIM Groups (#27702) 2025-04-02 17:10:40 -05:00
policies 🧹 friday cleanup party: substitute deprecated import of go-kit (#19774) 2024-06-17 10:27:31 -03:00
ptr Added better handling of timeout and insufficient permissions errors in NDES SCEP proxy. (#23654) 2024-11-11 14:57:28 -06:00
pubsub Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
service Add GitOps for policy labels (#27781) 2025-04-04 09:46:51 -05:00
shellquote Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
sso Merge commit from fork 2025-03-05 07:31:17 -06:00
test Bugfix: support removing labels associated with profiles (custom settings) in gitops (#27546) 2025-03-31 11:42:43 -04:00
version Move external dependency fleetdm/kolide-kit to monorepo (#15861) 2024-01-02 18:22:52 -03:00
vulnerabilities Fix non-Windows false positive for CVE-2024-6286 (#27325) 2025-03-20 09:21:42 -05:00
webhooks Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
websocket Enable errcheck linter for golangci-lint (#8899) 2022-12-05 16:50:49 -06:00
worker Added signed URLs (#25197) 2025-01-09 12:56:54 -06:00
utils.go Allow opting in users to email verification on login (#24273) 2024-12-05 08:37:10 -06:00
utils_test.go feature: target profiles by labels (#16202) 2024-01-26 11:00:58 -05:00