fleet/pkg/spec
Scott Gress 2bf46b14ad
Detect unknown keys in top-level GitOps settings (#41303)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #41280

# Details

Phase 2 of the "detect unknown keys in GitOps" work. The `org_settings`
and `settings` top-level keys mainly shadow the `fleet.AppConfig` and
`fleet.TeamConfig` types, but they have a couple of extra GitOps-only
fields, so we add new GitOps-specific types for them (similar to what we
already have for `GitOpsControls` and `GitOpsSoftware`. The
`org_settings:` case is further complicated by the fact that its extra
fields are themselves `any` types which we need to parse, so we add
those to the `anyFieldTypes` registry in the validator to tell it what
types to check them against.

Also had to add some new logic to handle the GoogleCalendarAPI case
which doesn't expose its keys as `json` tags at all, since we use a
special method to obfuscate the values.

I've tested this by routing the output from `fleetctl generate_gitops`
back through `fleetctl gitops`, which is how I caught the
`end_user_license_agreement` issue.

# 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 - already added in previous PR

## Testing

- [X] Added/updated automated tests
- [X] QA'd all new/changed functionality manually
Did the `fleetctl generate-gitops` -> `fleetctl gitops` loop as
mentioned above.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **New Features**
* Added support for managing secrets and certificate authorities through
GitOps configuration
* Improved detection of configuration errors with clear error messages
when using unknown or misspelled settings keys, including suggestions
for common typos
* Enhanced error reporting for nested configuration files with precise
location information

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ian Littman <iansltx@gmail.com>
2026-03-11 08:26:39 -05:00
..
testdata Add aliases for macos fields (#40959) 2026-03-05 18:08:54 -06:00
gitops.go Detect unknown keys in top-level GitOps settings (#41303) 2026-03-11 08:26:39 -05:00
gitops_deprecations.go Add more deprecation logs and mute by default (#40305) 2026-02-23 23:09:08 -06:00
gitops_test.go Detect unknown keys in top-level GitOps settings (#41303) 2026-03-11 08:26:39 -05:00
gitops_validate.go Detect unknown keys in top-level GitOps settings (#41303) 2026-03-11 08:26:39 -05:00
gitops_validate_test.go Detect unknown keys in top-level GitOps settings (#41303) 2026-03-11 08:26:39 -05:00
spec.go avoid double encoding $FLEET_SECRET in GitOps (#40866) 2026-03-03 14:14:58 -05:00
spec_test.go Add aliases for macos fields (#40959) 2026-03-05 18:08:54 -06:00