fleet/changes
Scott Gress 26e4395926
Allow GitOps to clear global settings more easily using overwrite option (#29215)
for #28118 

# Checklist for submitter

- [X] Manual QA for all new/changed functionality

## Details

This PR adds an `overwrite` option to the "modify app config" API which,
if set, causes the code to replace certain keys in the existing config
with keys from the incoming config, without attempting any merge. This
is then used by GitOps to allow it to easily clear settings that were
otherwise being merged together or ignored entirely due to the PATCH
semantics expected for the `fleetctl apply` use case.

The new setting is utilized in this first pass for the following
settings:

* `sso_settings`
* `smtp_settings`
* `features`
* `mdm.end_user_authentication`

It could be expanded to several more keys that we currently handle
piecemeal in the GitOps code by attempting to send empty values to the
server (with varying success).

Targeting `mdm.end_user_authentication` vs. all of `mdm` is based on
[this bug](https://github.com/fleetdm/fleet/issues/26175) being opened.
The concern with doing all of `mdm` would be that anyone who had e.g.
VPP set up in their app and hadn't set it up in GitOps would have it
wiped out. If we're comfortable with that risk I can update that here
and update the warning accordingly.

### More detail 

**The way this code works _without_ Overwrite mode on**

1. We unmarshall the incoming JSON from GitOps into a fresh AppConfig
struct `newAppConfig`. Anything keys not present in the incoming JSON
will result in default values being set in `newAppConfig`
2. We unmarshall the incoming JSON from GitOps into the current
`appConfig`. This uses an internal merge algorithm where keys not
present in the JSON will generally leave the matching keys in
`appConfig` untouched. We've been dealing with this by having GitOps
find missing keys and explicitly set them to non-nil empty states. When
arrays are encountered, they are _merged_, not replaced, which is
problematic for the `features.additional_queries` use case and probably
others.
3. We piecemeal replace certain data in `appConfig` with data from
`newAppConfig`, and save it to the db.

**The way this works _with_ Overwrite mode on**

Between steps 1 and 2 above, we _copy_ certain keys from `newAppConfig`
to `appConfig`. If the incoming JSON didn't have a key, the effect will
be that `appConfig` now has default values for that key. For nested
arrays like `features.additionalQueries`, the value in `appConfig` will
be precisely what the user put in GitOps.

## Testing

I tested adding/removing these settings with GitOps manually via
`fleetctl gitops`. On the main branch I could reproduce the issue where
omitting out these keys in my YAML did not lead to the settings being
reset on my instance. With the Features settings, the issue was more
granular, with inconsistent behavior when trying to remove individual
nested settings. On this branch, the settings are cleared as expected at
all levels of granularity.

I also added some new automated tests to verify the expected behavior
for these keys. All existing tests pass.

If accepted this PR would supercede
https://github.com/fleetdm/fleet/pull/29180 which approaches the issue
from the GitOps side for sso, smtp and mdm. Adapting that approach for
`features` would require custom logic to declare nested properties as
"cleared".
2025-05-19 11:18:28 -05:00
..
.keep Issue 1009 calculate diff software (#1305) 2021-07-08 13:57:43 -03:00
10098-org-logo Handle wide logos in MDM setup experience and migration dialog on Apple devices (#28539) 2025-04-29 09:39:28 -05:00
17710-apple-host-mdm-timestamps Fix MDM last checkin and enrollment names to match API spec (#29073) 2025-05-13 08:17:11 -04:00
19235-microsoft-compliance-conditional-access UI: Conditional access - Microsoft Entra (#27982) 2025-04-15 13:55:07 -07:00
23497-gitops-sha enable specifying installers by SHA256 in gitops (#28349) 2025-04-18 16:41:41 -04:00
24083-app-metadata Improve .pkg metadata extraction for names and bundle IDs, let custom package metadata extraction tool check an entire directory at a time (#29249) 2025-05-19 10:32:36 -05:00
24087-app-names fix: change how macOS software names are calculated to avoid erroneous duplicates (#28037) 2025-04-11 19:19:07 -04:00
24087-migration-perf-improvement Batch host_software inserts in macOS names migration to improve performance for large host counts (#29238) 2025-05-17 12:42:01 -05:00
24209-windows-mdm-error-msg Update API message for Windows MDM not configured error (#28247) 2025-04-15 13:52:17 -05:00
24394-wlan-xml-profile-verification Update WLAN XML profile verification so they aren't resent (#28296) 2025-04-18 08:45:18 -04:00
24469-fleetctl-fma-apps Fleet UI: Add FMA gitops to FMA details and update activity feed (#27878) 2025-05-08 09:22:55 -04:00
24469-FMA-gitops Support for fleet maintained apps in gitops (#28751) 2025-05-07 18:16:08 -05:00
24475-manual_agent_install Added macos_setup.manual_agent_install to global/team config (#28419) 2025-04-24 15:18:01 -05:00
24878-renew-ndes NDES cert renewal (#28712) 2025-05-01 12:16:45 -05:00
25700-luks-escrow-longtime Removed indicator for background LUKS validation (#28218) 2025-04-16 12:25:41 -04:00
26114-new-team-with-vpp-apps Fixed fleetctl gitops issue where creating a new team containing VPP apps caused an error. (#28624) 2025-04-29 16:28:25 -05:00
26366-update-sql-parser Update SQL parser to handle more modern syntax (#28211) 2025-04-16 10:10:52 -05:00
26553-renew-digicert Renewal of DigiCert certificates on macOS (#28449) 2025-04-24 08:35:15 -04:00
26674-update-disk-info-docs update docs about disk_info table (#28795) 2025-05-06 15:28:07 -05:00
26692-upload-install-tarballs Fleet UI: Upload and install tarball archives (#27839) 2025-05-02 10:17:09 -04:00
27003-list-host-software Refactoring ListHostSoftware (#27490) 2025-04-10 17:29:15 -05:00
27007-host-certificate-serial-display Display host certificate decimal serials in addition to hex for smaller values to match keychain (#28732) 2025-05-01 14:29:11 -04:00
27052-round-live-policy-percentages UI: Fix live policy response percentage rounding (#28719) 2025-05-01 10:03:23 -07:00
27255-hide-script-content-for-saved-scripts UI: Hide script contents for saved script run activity details (#29064) 2025-05-13 11:16:27 -07:00
27436-query-automation-query-ids Add query IDs to query automation logs (#28570) 2025-05-01 15:21:30 -04:00
27445-webhook-automation-backend Webhook logging destination (#28692) 2025-05-01 16:13:04 -04:00
27458-update-calendar-events Update Google Calendar event bodies and relevant previews in the Fleet UI (#28715) 2025-05-01 13:12:53 -07:00
27463-add-script-syntax-highlighting Add syntax highlighting support for shell and powershell scripts (#28417) 2025-04-29 10:24:05 -05:00
27475-fix-query-page-selection-clear Fx query page clearing selection after load (#28228) 2025-04-16 10:10:21 -05:00
27476-add-generate-gitops-cmd Add "generate-gitops" command (#28555) 2025-05-06 15:25:44 -05:00
27477-do-not-interpolate-gitops-text-sections Exclude certain sections from var interpolation when running gitops cmd (#28625) 2025-04-29 15:09:25 -04:00
27501-clear-windows-mdm-info-on-linux-enroll Clear host_mdm table row when existing Windows hosts enroll as a different OS (#28463) 2025-04-23 08:53:24 -04:00
27522-installer-encoding Properly decode MSI product names from Windows-1252 (#29245) 2025-05-19 10:39:57 -05:00
27609-user-menu-style UI: User menu style fix (#29066) 2025-05-13 11:49:48 -07:00
27700-validate-bootstrap-is-distribution-pkg Only allow distribution packages for bootstrap package (#28787) 2025-05-06 11:02:13 -05:00
27822-dep-host-cleanup Fix CleanupExpiredHosts to prevent deletion of DEP-assigned hosts (#28313) 2025-04-18 12:49:03 -05:00
27854-force-profile-assign-on-abm-add Force enrollment profile sync when an Apple device was added to ABM. (#29147) 2025-05-15 12:29:38 -05:00
27867-fix-chrome-profiles-not-reset-after-reenroll Immediately ask for a host refetch when a host re-enrolls and reuses an existing host row (#29081) 2025-05-14 09:38:53 -04:00
27909-hover-checkbox-radio Fleet UI: Added hover cursors to checkbox and radio components (#28113) 2025-04-16 13:29:08 -04:00
27941-GOM-shouldn't-apply-to-VPP-token UI: Allow VPP token upload in GitOps mode (#28746) 2025-05-02 09:31:36 -07:00
27979-ddm-profile-verification Fixing issues with Apple DDM profile status (#29059) 2025-05-15 13:05:25 -05:00
28032-email-to-header Add To: header when constructing emails (#28507) 2025-04-24 09:00:35 -04:00
28033-support-end-user-idp-fleet-vars IdP vars: Populate IdP fleet variables in macOS configuration profiles (#28291) 2025-04-22 09:09:00 -04:00
28038-uninstall Add backend for uninstalls in My device UI (#29035) 2025-05-13 12:14:45 -05:00
28049-conditional-access-fe-updates UI: Update conditional access on a per-policy basis (#28658) 2025-05-01 11:43:38 -07:00
28054-surface-policy-count-triggering-install Fleet UI: Surface policy count triggering automatic installations (#28726) 2025-05-02 11:01:26 -04:00
28099-sha-hash Fleet UI: Surface copyable SHA256 hash on software details page (#29152) 2025-05-15 12:20:22 -04:00
28118-clear-gitops-settings Allow GitOps to clear global settings more easily using overwrite option (#29215) 2025-05-19 11:18:28 -05:00
28137-my-device-page-layout-changes Fleet UI: Device user/Host details page layout changing including split out host header and summary card (#28598) 2025-04-28 13:00:13 -04:00
28138-categories-be software categories: backend (#28479) 2025-05-02 11:41:26 -04:00
28154-fix-gitops-dry-run-labels Don't validate software/profile labels in dry run mode (#28201) 2025-04-17 08:39:24 -05:00
28158-batch-script-backend Bulk script execution backend (#28299) 2025-04-30 12:54:46 -04:00
28159-batch-scripts UI: Add ability to run scripts on batches of hosts (#28563) 2025-04-28 16:32:41 -07:00
28166-webhook-logging UI: Support webhook logging configuration (#28737) 2025-05-02 09:04:05 -07:00
28196-SCIM-for-Entra-ID SCIM Entra ID support (#28832) 2025-05-08 13:02:49 -05:00
28197-SCIM-for-authentik SCIM support for authentik (#29002) 2025-05-09 15:06:03 -04:00
28205-skip-policies-during-setup-experience Hold off on policy queries until after setup experience (#29159) 2025-05-16 14:56:27 -04:00
28240-log-invalid-soap-msg Log invalid SOAP message and return 400 (#28340) 2025-04-18 11:13:30 -05:00
28266-clean-up-settings UI: Clean up various states on the Settings page (#28752) 2025-05-02 09:14:30 -07:00
28343-reverting-some-mcx-validation Removing Apple MDM profile validation checks for some com.apple.MCX keys (#28498) 2025-04-23 14:06:17 -05:00
28379-vpp-app-install-status Fleet UI: VPP apps with self service shows correct install status (#28739) 2025-05-02 10:41:06 -04:00
28411-self-service-install-status Implement self-service install status endpoints (#28424) 2025-04-24 12:20:21 -05:00
28440-deleting-non-managed-gitops-labels Error when deleting non managed GitOps labels #28440 (#29067) 2025-05-13 20:16:16 -04:00
28443-add-hash-to-software-title-response Add hash_sha256 field to "List Software Titles" API response (#28447) 2025-04-24 12:08:59 -05:00
28543-exe-edits Fix broken installer PATCH (always failing with "missing install script" error) on EXEs (#28670) 2025-04-29 17:53:52 -05:00
28560-add-neon-to-linux-platforms Add neon to Linux platform list (#28977) 2025-05-12 17:37:21 -05:00
28616-renew-custom-scep Custom SCEP renewal (#28616) 2025-04-30 15:31:45 -04:00
28652-copy-button-consistency Fleet UI: Created consistent UI for the copy button of an input field (#29056) 2025-05-13 10:24:32 -04:00
28743-gom-premium-only UI: Premium feature message when viewing GitOps Mode toggle on Fleet Free (#28744) 2025-05-02 09:34:37 -07:00
28747-allow-advanced-save-in-GOM UI: Enable Integrations > Advanced save button in GitOps Mode (#28748) 2025-05-02 09:32:34 -07:00
28762-batch-resend-profile-to-hosts BRP: add batch-resend profile to hosts endpoint based on status (#28871) 2025-05-07 16:48:18 -04:00
28857-vuln-checks Add spot check on 2024 and 2025 NVD feeds to ensure VulnCheck enrichment (#28952) 2025-05-08 22:13:46 -05:00
28929-fleet-desktop-errors Fleet Desktop: Update component level error states (#28816) 2025-05-12 09:25:09 -04:00
48642-add-retry-to-apply-queries Add retry when applying queries (#28951) 2025-05-13 12:06:20 -05:00
C10298-additional-stats Add statistic to measure ABM pending hosts (#28226) 2025-04-15 11:30:07 -04:00
issue-23784-turn-off-mdm-iphone-ipad allow turning off mdm for iphone and ipad hosts (#29087) 2025-05-15 12:38:07 +01:00
issue-26070-add-ui-for-manual-agent-install Add UI for enabling manual agent install of a bootstrap package (#28550) 2025-04-29 15:29:21 +01:00
issue-26148-remove-config-settings-when-no-team-removed remove no team gitops setting when no-team.yml is not supplied (#28082) 2025-04-22 16:40:17 +01:00
issue-26505-keyboard-accssibility-to-activites Add keyboard accessibility controls to the activity items on host details and dashboard pages (#28433) 2025-04-25 10:21:56 +01:00
issue-27198-long-host-name add truncation and tooltip to host details host with long name (#28547) 2025-04-28 17:09:42 +01:00
issue-27775-fix-activity-date-tooltip Fix host upcoming activites showing wrong created at date in tooltip (#28242) 2025-04-16 10:17:48 +01:00
issue-28215-allow-fleet-secrets-for-macos-setup-script enable fleet secret variables in the macos setup script in gitops (#29164) 2025-05-16 19:05:33 +01:00
issue-28757-ui-for-profiles-status-and-batch-resend Add UI for viewing config profile install status and enable resending profiles to failed hosts. (#28964) 2025-05-09 16:46:09 +01:00
issue-28759-ui-for-filter-hosts-by-config-profile-status Feat UI host filter by custom profiles (#29038) 2025-05-15 12:37:45 +01:00
update-go-1.24.2 Fix detected CVEs and docker scout exit code to fail the Github Action (#28836) 2025-05-06 13:35:27 -03:00
warn-on-save-script UI: Warn before saving script contents (#29026) 2025-05-12 13:51:38 -07:00