Skip to content

Add gitops endpoints to api_endpoints catalog#44291

Merged
juan-fdz-hawa merged 4 commits intomainfrom
44279-fleetctl-gitops-returns-403-on-gitops-endpoints
Apr 28, 2026
Merged

Add gitops endpoints to api_endpoints catalog#44291
juan-fdz-hawa merged 4 commits intomainfrom
44279-fleetctl-gitops-returns-403-on-gitops-endpoints

Conversation

@juan-fdz-hawa
Copy link
Copy Markdown
Contributor

@juan-fdz-hawa juan-fdz-hawa commented Apr 28, 2026

Related issue: Resolves ##44279

Add gitops endpoints to api_endpoints catalog

Checklist for submitter

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

Testing

  • Added/updated automated tests

Summary by CodeRabbit

  • New Features

    • Added many new Fleet API endpoints (config patch, batch script run, current-user, label/spec ops, ABM token count, certificate authority/template/certificate spec ops, secret variable save, spec apply for reports/policies/fleets, policy list/delete, MDM profile batch/bootstrap metadata, batch software installer/app store app ops, fleet‑maintained app listing/detail, software title icon get/update/delete). Fixed formatting for a configuration-profile status entry.
  • Tests

    • Added integration tests verifying API-only GitOps access and fine-grained endpoint allow-list behavior.

@juan-fdz-hawa juan-fdz-hawa requested a review from a team as a code owner April 28, 2026 15:23
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

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: 3c5ec6f3-d823-4086-a886-9262634aac0b

📥 Commits

Reviewing files that changed from the base of the PR and between ed8f25b and fa64cbf.

📒 Files selected for processing (1)
  • server/api_endpoints/api_endpoints.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/api_endpoints/api_endpoints.yml

Walkthrough

Extends the Fleet API endpoint registry (server/api_endpoints/api_endpoints.yml) with ~25 new route declarations (PATCH/POST/GET/PUT/DELETE across fleet config, scripts batch, current-user, spec resources, ABM tokens, certificate authorities/templates, secret variables, reports/policies/fleets specs, policy listing/deletion, MDM profiles/bootstrap, software batch/app association/fleet-maintained apps, and software title icons). Fixes newline/EOF formatting for an existing configuration profile status entry. Adds two enterprise integration tests validating api-only access and endpoint-restriction behavior for GitOps-related routes.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. While it includes the related issue and confirms testing was added, it is missing most required checklist items such as database migrations, input validation, and compatibility checks. Complete the checklist by either checking off applicable items or explicitly deleting sections that don't apply to this change. Provide details on any skipped items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change—adding GitOps endpoints to the API endpoints catalog, which aligns with both the file changes and PR objectives.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 44279-fleetctl-gitops-returns-403-on-gitops-endpoints

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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.79%. Comparing base (9609f0a) to head (fa64cbf).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #44291      +/-   ##
==========================================
+ Coverage   66.78%   66.79%   +0.01%     
==========================================
  Files        2630     2630              
  Lines      211232   211354     +122     
  Branches     9510     9547      +37     
==========================================
+ Hits       141063   141181     +118     
- Misses      57348    57349       +1     
- Partials    12821    12824       +3     
Flag Coverage Δ
backend 68.58% <ø> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Member

@lucasmrod lucasmrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left two comments to tackle.

Comment thread server/api_endpoints/api_endpoints.yml Outdated
Comment on lines +541 to +543
- method: "POST"
path: "/api/v1/fleet/spec/packs"
display_name: "Apply packs spec"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double checking: Do we support setting the (deprecated) "user packs" in GitOps?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it

Comment thread server/api_endpoints/api_endpoints.yml Outdated
Comment on lines +550 to +552
- method: "POST"
path: "/api/v1/fleet/users/roles/spec"
display_name: "Apply user roles spec"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this (for security purposes, to not allow these users to create users with more power).
GitOps doesn't use it (fleetctl apply uses it, but we don't need to support fleetctl apply for API-only users without API-endpoints.)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
server/service/integration_enterprise_test.go (1)

29153-29157: Add a timeout to the HTTP request helper.

The assertNot403 helper uses http.DefaultClient.Do(req) (line 29156) without a timeout. If the handler stalls, this test can hang indefinitely in CI. Use http.NewRequestWithContext(t.Context(), ...) instead of http.NewRequest(...) to leverage the per-test timeout.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/service/integration_enterprise_test.go` around lines 29153 - 29157,
The test helper assertNot403 creates requests with http.NewRequest(...); change
it to create the request with the test's context using
http.NewRequestWithContext(t.Context(), verb, s.server.URL+path,
bytes.NewReader(raw)) so the per-test timeout/cancellation is honored, then
proceed to set the Authorization header and call http.DefaultClient.Do(req) as
before; ensure you still check require.NoError(t, err) after creating the
request and after doing the request.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@server/service/integration_enterprise_test.go`:
- Around line 29153-29157: The test helper assertNot403 creates requests with
http.NewRequest(...); change it to create the request with the test's context
using http.NewRequestWithContext(t.Context(), verb, s.server.URL+path,
bytes.NewReader(raw)) so the per-test timeout/cancellation is honored, then
proceed to set the Authorization header and call http.DefaultClient.Do(req) as
before; ensure you still check require.NoError(t, err) after creating the
request and after doing the request.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 94f2b901-8ae5-4d66-82b1-d52077d0c019

📥 Commits

Reviewing files that changed from the base of the PR and between dc93dea and 6b81a3d.

📒 Files selected for processing (2)
  • server/api_endpoints/api_endpoints.yml
  • server/service/integration_enterprise_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/api_endpoints/api_endpoints.yml

lucasmrod
lucasmrod previously approved these changes Apr 28, 2026
@juan-fdz-hawa juan-fdz-hawa merged commit 7aea2e3 into main Apr 28, 2026
41 checks passed
@juan-fdz-hawa juan-fdz-hawa deleted the 44279-fleetctl-gitops-returns-403-on-gitops-endpoints branch April 28, 2026 19:04
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.

4.85.0-RC regression: fleetctl gitops returns 403 on /spec/labels for api-only tokens

2 participants