Skip to content

Add GitOps name_template under controls#48892

Merged
juan-fdz-hawa merged 1 commit into
38806-macos-iosipados-rename-hostsfrom
48625-rename-hosts-gitops-name_template-under-controls
Jul 9, 2026
Merged

Add GitOps name_template under controls#48892
juan-fdz-hawa merged 1 commit into
38806-macos-iosipados-rename-hostsfrom
48625-rename-hosts-gitops-name_template-under-controls

Conversation

@juan-fdz-hawa

@juan-fdz-hawa juan-fdz-hawa commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Relates to #48625

Lets GitOps own the host name template via controls.name_template in team YAML. Parsed into GitOpsControls (with type validation and Set() presence check), applied declaratively through the same team-spec path as the endpoint (absent key clears the template), and rejected for org-level and no-team controls. generate-gitops emits controls field-by-field and does not include name_template, so it does not round-trip (matches the story's 'No changes' for generation).

Related issue: Resolves #

Checklist for submitter

If some of the following don't apply, delete the relevant line.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features

    • Added support for configuring a host name template in GitOps for fleet/team setups.
    • GitOps exports now include this setting for applicable team configurations.
  • Bug Fixes

    • Improved validation so the host name template must be a valid string.
    • Prevented this setting from being used in org-level or “No team” configurations.
    • Re-applying the same configuration now behaves consistently without duplicate changes.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (38806-macos-iosipados-rename-hosts@f278514). Learn more about missing BASE report.

Files with missing lines Patch % Lines
server/service/client.go 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                          Coverage Diff                          @@
##             38806-macos-iosipados-rename-hosts   #48892   +/-   ##
=====================================================================
  Coverage                                      ?   68.04%           
=====================================================================
  Files                                         ?     3683           
  Lines                                         ?   234297           
  Branches                                      ?    12419           
=====================================================================
  Hits                                          ?   159422           
  Misses                                        ?    60529           
  Partials                                      ?    14346           
Flag Coverage Δ
backend 69.69% <88.23%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@juan-fdz-hawa juan-fdz-hawa force-pushed the 48625-rename-hosts-gitops-name_template-under-controls branch from 8ca08a1 to a982acb Compare July 8, 2026 12:55
@juan-fdz-hawa

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

Relates to #48625

Lets GitOps own the host name template via controls.name_template in team
YAML. Parsed into GitOpsControls (with type validation and Set() presence
check), applied declaratively through the same team-spec path as the
endpoint (absent key clears the template), and rejected for org-level and
no-team controls.

generate-gitops emits name_template for real fleets (fleets-only: omitted
for org and No team) so a generate -> apply round-trip preserves a set
template rather than silently clearing it — same declarative contract as
enable_disk_encryption.
@juan-fdz-hawa juan-fdz-hawa force-pushed the 48625-rename-hosts-gitops-name_template-under-controls branch from a982acb to ef83dc9 Compare July 8, 2026 13:02
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4ad01756-8af8-4919-9080-01a192b11f0b

📥 Commits

Reviewing files that changed from the base of the PR and between f278514 and a982acb.

📒 Files selected for processing (7)
  • cmd/fleetctl/fleetctl/generate_gitops.go
  • cmd/fleetctl/fleetctl/gitops_test.go
  • cmd/fleetctl/fleetctl/testdata/generateGitops/teamConfig.json
  • cmd/fleetctl/fleetctl/testdata/generateGitops/test_dir_premium/fleets/team-a-thumbsup.yml
  • pkg/spec/gitops.go
  • pkg/spec/gitops_test.go
  • server/service/client.go

Walkthrough

This PR adds support for a new controls.name_template field in GitOps configuration, restricted to fleet/team-level scope. Changes include a new NameTemplate field on GitOpsControls with type validation during parsing, conditional emission of the field during GitOps YAML generation for real fleets (excluding org/global and "No team" exports), and client-side handling in DoGitOps that applies the template to team MDM config while rejecting it at org-level or "No team" scope. Test fixtures and new unit/integration tests cover parsing validation, generation output, and end-to-end apply behavior including dry-run, idempotent re-apply, removal, activity emission, and error cases for invalid templates or disallowed scopes.

Possibly related issues

Possibly related PRs

  • fleetdm/fleet#48693: This PR's GitOps name_template parsing/apply drives the persistence/reconcile logic that upserts/deletes host-name enforcement rows based on mdm.name_template.
  • fleetdm/fleet#48699: This PR's fleet-only enforcement and activity emission for edited_host_name_template builds on the host name template activity type and validation logic introduced there.
  • fleetdm/fleet#48774: This PR's GitOps generation/parsing/apply of name_template uses the same underlying team-level host name template update pathway (UpdateMDMNameTemplate/UpdateTeamMDMNameTemplate) introduced there.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning It omits the GitOps-setting checklist details and leaves the "Related issue" line incomplete. Fill in the new-setting GitOps checklist items and replace "Resolves #" with the correct issue number or remove it.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Concise and specific; it clearly matches the main GitOps name_template change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 48625-rename-hosts-gitops-name_template-under-controls

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@juan-fdz-hawa juan-fdz-hawa marked this pull request as ready for review July 8, 2026 13:09
@juan-fdz-hawa juan-fdz-hawa requested a review from a team as a code owner July 8, 2026 13:09
@juan-fdz-hawa juan-fdz-hawa linked an issue Jul 8, 2026 that may be closed by this pull request
@juan-fdz-hawa juan-fdz-hawa merged commit adb1cc7 into 38806-macos-iosipados-rename-hosts Jul 9, 2026
40 checks passed
@juan-fdz-hawa juan-fdz-hawa deleted the 48625-rename-hosts-gitops-name_template-under-controls branch July 9, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename hosts: GitOps name_template under controls

2 participants