Adding the logic to make controls even when it's empty - #50836
Conversation
Signed-off-by: Kitarp29 <kitarpsinghrajpoot@gmail.com>
Walkthrough
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/fleetctl/fleetctl/generate_gitops.go`:
- Around line 564-569: Update the serialization/rewrite logic following
generateControls so an empty controls map remains serialized as controls: {}
rather than being replaced with a blank value. Preserve the existing behavior
for non-empty controls, and add a regression case covering a team with no
generated controls.
- Around line 564-569: Update generateControls so the organization-level status
field assignments around the teamId checks are performed only when teamId is nil
or points to team 0. Preserve the existing control generation for regular team
fleets, but prevent global organization-level fields from being emitted for
non-global team outputs.
In `@cmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/default.yml`:
- Line 258: Update the Android status fixture to match generateControls: remove
android_enabled_and_configured when AndroidEnabledAndConfigured is false, or
adjust the fixture and corresponding global/no-team controls to emit both status
fields explicitly only when the generator does so. Ensure the generated output
cannot include this key with a false value.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2830faaf-5e54-4d18-a07e-4d2935868598
📒 Files selected for processing (2)
cmd/fleetctl/fleetctl/generate_gitops.gocmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/default.yml
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #50836 +/- ##
==========================================
- Coverage 68.53% 68.53% -0.01%
==========================================
Files 3977 3977
Lines 256142 256141 -1
Branches 13818 13818
==========================================
- Hits 175553 175541 -12
- Misses 64973 64983 +10
- Partials 15616 15617 +1
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:
|
Related issue: Resolves #50300, Resolves #50276
Description
This PR fixes two scoped issues with GitOps configuration generation (
fleetctl generate-gitops):fleetctl generate-gitopsemits org-levelwindows_enabled_and_configured/android_enabled_and_configuredinto per-fleet YAML files #50300: Moved the emission ofwindows_enabled_and_configuredandandroid_enabled_and_configuredinside the global-only guard block (teamId == nil || *teamId == 0) ingenerateControls. This prevents org-level MDM configurations from improperly leaking into per-fleet YAML files.controlsdictionary is always initialized and appended to the global GitOps output (even as an empty map{}). This preventsfleetctl gitopsfrom failing validation with'controls' must be set on global configwhen applying the generated files.Checklist for submitter
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
SELECT *is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.Testing
For unreleased bug fixes in a release candidate, one of:
New Fleet configuration settings
If you didn't check the box above, follow this checklist for GitOps-enabled settings:
fleetctl generate-gitopsSummary by CodeRabbit
New Features
Bug Fixes