Add "No Team" integration configurations for Jira and Zendesk - #32387
Conversation
- Implements datastore methods for managing "No Team" configuration. - Introduces deep copy methods for `TeamConfig`, `SoftwareSpec`, and `Integrations`. - Updates tests to validate default team configuration workflows.
- Add support for modifying and retrieving "No Team" configurations in `ModifyTeam` and `GetTeam`. - Implement validation for team webhook settings, ensuring required fields are present. - Update policy failing logic to respect default team configurations. - Refactor automation configuration to support "No Team" settings.
- Update schema.sql to set consistent timestamps for the default team configuration entry. - Adjust migration to include `created_at` and `updated_at` fields with fixed timestamp values.
- Introduced comprehensive test cases for configuring and updating webhook settings for the "No Team" (team ID 0). - Verified proper handling of failing policy webhooks and host status webhooks for "No Team". - Ensured accurate recording and triggering of failing policy automations for policies associated with "No Team".
- Added tests to verify failing policy webhook trigger for "No Team" (team ID 0). - Enhanced test cases for policy automation resets and validation of webhook configurations. - Updated logic to handle "No Team" configurations in policy automation pathways.
…alidations - Added support for specifying `team_settings` on `no-team.yml` with `webhook_settings` for `failing_policies_webhook`. - Refactored logic to validate and process `webhook_settings` exclusively for "No Team". - Updated tests to cover multiple scenarios, including valid, invalid, and updated configurations for "No Team" webhook settings. - Enhanced integration tests to validate database changes and dry-run functionality.
… endpoint - Introduce `DefaultTeam` struct with reduced fields for handling "No Team" responses. - Add special case in `getTeamEndpoint` to return `DefaultTeam` for team ID 0 with limited webhook configuration details.
…ctions in tests - Moved `DefaultTeam` struct and associated types to `fleet` package for shared usage. - Updated `ModifyTeam` and `GetTeam` endpoints to incorporate specific handling for "No Team" (team ID 0). - Added mock implementation for `DefaultTeamConfigFunc` to test workflows and validations. - Enhanced unit tests to cover new `DefaultTeam` configurations and behaviors.
…andling - Removed redundant test cases related to HostStatusWebhook configuration. - Refactored `DefaultTeam` struct and associated logic for streamlined handling of team ID 0 in `getTeamEndpoint`.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…urations - Updated `SoftwareSpec.Copy` and `TeamConfig.Copy` to improve deep copy handling. - Enhanced validation for `webhook_settings` in "No Team" configurations. - Simplified retrieval of default team webhook settings in tests.
- Added support for `null` values in `webhook_settings` to clear configurations. - Improved validation for `failing_policies_webhook` to allow `null` or object types. - Updated `doGitOpsNoTeamWebhookSettings` to check premium license before applying configurations. - Enhanced integration handling for `appConfig` in webhook processing logic.
- Introduced mock implementations for `DefaultTeamConfigFunc` and `SaveDefaultTeamConfigFunc` in test utilities. - Simplified test logic by consolidating `DefaultTeamConfig` setup via a helper function.
- Updated error messages in tests to use semicolons instead of dashes for consistency.
…ests - Introduced detailed timestamped logs to track profile job triggers, completion statuses, and host transfers in MDM-related integration tests. - Added timeout handling for profile schedule triggers with appropriate logging for completions or timeouts. - Enhanced visibility into the execution flow of `awaitTriggerProfileSchedule` and related cron jobs.
…ok settings - Implemented validation to ensure `policy_ids` is an array if present. - Introduced `validateTeamWebhookSettings` and `validateFailingPoliciesWebhook` for structured validation. - Updated tests to cover various valid and invalid configurations for `policy_ids`.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #32387 +/- ##
==========================================
- Coverage 64.02% 62.13% -1.89%
==========================================
Files 1986 1985 -1
Lines 195474 195521 +47
Branches 6467 6467
==========================================
- Hits 125144 121482 -3662
- Misses 60535 64363 +3828
+ Partials 9795 9676 -119
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WalkthroughUpdates add default team integrations (Jira/Zendesk) types and wiring, extend default team service logic to accept/validate integrations and automation constraints, adjust GetTeam/ModifyTeam endpoint flows for ID 0 handling, tweak gitops generation for team integrations output, and add clarifying comments in gitops spec and CLI generation. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant S as Service (API)
participant DS as Datastore
Note over S: GetTeam (ID may be 0 or non-zero)
C->>S: GET /api/latest/fleet/teams/{id}
S->>DS: GetTeam(ctx, id)
DS-->>S: Team {ID, Config.Integrations, ...} or error
alt error
S-->>C: getTeamResponse{Err}
else team.ID == 0
Note over S: Construct DefaultTeam with WebhookSettings + Integrations (Jira/Zendesk)
S-->>C: getDefaultTeamResponse{DefaultTeam}
else team.ID != 0
S-->>C: getTeamResponse{Team}
end
sequenceDiagram
autonumber
participant C as Client
participant S as EE Service (Default Team)
participant DS as Datastore
participant AC as App Config
Note over S: modifyDefaultTeamConfig (No Team)
C->>S: PATCH default team config (WebhookSettings/Integrations)
alt Integrations provided (Jira/Zendesk possibly present)
S->>DS: GetAppConfig(ctx)
DS-->>S: AppConfig
S->>S: MatchWithIntegrations(AppConfig.Integrations)
S->>S: Validate uniqueness (Integrations.Validate)
alt invalid
S-->>C: 400 InvalidArgument("integrations")
end
end
S->>S: Apply webhook/integration updates to config
S->>S: Validate automations<br/>(ValidateEnabledFailingPoliciesTeamIntegrations)
alt invalid combo
S-->>C: 400 error
else valid
S->>DS: SaveDefaultTeamConfig(ctx, config)
DS-->>S: ok
S-->>C: success
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
server/service/teams.go (1)
154-165: Inconsistent response shape for team ID 0 on success (Team vs DefaultTeam).GET /teams/0 returns DefaultTeam, but PATCH /teams/0 returns Team on success. This breaks response-shape consistency for clients handling No Team.
Apply:
func modifyTeamEndpoint(ctx context.Context, request interface{}, svc fleet.Service) (fleet.Errorer, error) { req := request.(*modifyTeamRequest) team, err := svc.ModifyTeam(ctx, req.ID, req.TeamPayload) if err != nil { // For team ID 0, return appropriate error response if req.ID == 0 { return getDefaultTeamResponse{Err: err}, nil } return teamResponse{Err: err}, nil } - return teamResponse{Team: team}, err + if req.ID == 0 { + dt := &fleet.DefaultTeam{ + ID: team.ID, + Name: team.Name, + WebhookSettings: fleet.DefaultTeamWebhookSettings{ + FailingPoliciesWebhook: team.Config.WebhookSettings.FailingPoliciesWebhook, + }, + Integrations: fleet.DefaultTeamIntegrations{ + Jira: team.Config.Integrations.Jira, + Zendesk: team.Config.Integrations.Zendesk, + }, + } + return getDefaultTeamResponse{Team: dt}, nil + } + return teamResponse{Team: team}, nil }
🧹 Nitpick comments (2)
server/fleet/teams.go (1)
189-202: Consider omitting empty integrations in DefaultTeam responses.Without omitempty, clients will see
"integrations": {"jira": null, "zendesk": null}which is noisier and can break strict schemas. Recommend using omitempty on both the field and slice members (or make the field a pointer) to suppress empty/nulls.Apply:
type DefaultTeam struct { ID uint `json:"id"` Name string `json:"name"` WebhookSettings DefaultTeamWebhookSettings `json:"webhook_settings"` - Integrations DefaultTeamIntegrations `json:"integrations"` + Integrations *DefaultTeamIntegrations `json:"integrations,omitempty"` } -// DefaultTeamIntegrations contains only the integrations supported for team ID 0 -type DefaultTeamIntegrations struct { - Jira []*TeamJiraIntegration `json:"jira"` - Zendesk []*TeamZendeskIntegration `json:"zendesk"` -} +// DefaultTeamIntegrations contains only the integrations supported for team ID 0 +type DefaultTeamIntegrations struct { + Jira []*TeamJiraIntegration `json:"jira,omitempty"` + Zendesk []*TeamZendeskIntegration `json:"zendesk,omitempty"` +}Note: If you adopt this, also update call sites to set
Integrations: &fleet.DefaultTeamIntegrations{...}.server/service/teams.go (1)
80-83: Optional: Align error envelope for GET /teams/0 with DefaultTeam response.Currently errors for ID 0 return getTeamResponse. Consider returning getDefaultTeamResponse for symmetry.
- team, err := svc.GetTeam(ctx, req.ID) - if err != nil { - return getTeamResponse{Err: err}, nil - } + team, err := svc.GetTeam(ctx, req.ID) + if err != nil { + if req.ID == 0 { + return getDefaultTeamResponse{Err: err}, nil + } + return getTeamResponse{Err: err}, nil + }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
cmd/fleetctl/fleetctl/generate_gitops.go(2 hunks)ee/server/service/teams.go(1 hunks)pkg/spec/gitops.go(1 hunks)server/fleet/teams.go(1 hunks)server/service/teams.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
⚙️ CodeRabbit configuration file
When reviewing SQL queries that are added or modified, ensure that appropriate filtering criteria are applied—especially when a query is intended to return data for a specific entity (e.g., a single host). Check for missing WHERE clauses or incorrect filtering that could lead to incorrect or non-deterministic results (e.g., returning the first row instead of the correct one). Flag any queries that may return unintended results due to lack of precise scoping.
Files:
pkg/spec/gitops.goee/server/service/teams.goserver/fleet/teams.gocmd/fleetctl/fleetctl/generate_gitops.goserver/service/teams.go
🔇 Additional comments (4)
pkg/spec/gitops.go (1)
468-468: Comment-only update acknowledged; behavior remains consistent.The note aligns with the current restriction: No Team GitOps should only allow webhook_settings. No further action.
cmd/fleetctl/fleetctl/generate_gitops.go (1)
865-876: No Team export correctly limits to webhook_settings.The shape matches parseNoTeamSettings: only failing_policies_webhook is emitted. Good constraint.
ee/server/service/teams.go (1)
1856-1869: Mutual exclusivity validation between webhooks and integrations: LGTM.This correctly re-validates after applying changes to the working config.
server/service/teams.go (1)
85-99: DefaultTeam payload includes integrations: LGTM.The mapping from Team.Config to DefaultTeam is correct and mirrors the new DefaultTeam fields.
sgress454
left a comment
There was a problem hiding this comment.
Code looks good. Tested 👍 after setting initial integration config via manual PATCH request. Tested error states as well.
Fixes #32061 - Depends on the backend changes in #32387 for full functionality - Removed special case for primo mode # Checklist for submitter ## Testing - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Team-level configuration now supports the “No Team” selection (team 0). * Expanded availability of the “Other” option in the Automations dropdown for non-maintainers. * **Bug Fixes** * Team 0 loads correctly in Policies management. * Automations configuration correctly switches between global (All Teams) and team contexts, including No Team. * Post-update refresh behavior is consistent: global refresh for All Teams, team refresh otherwise. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Checklist for submitter
If some of the following don't apply, delete the relevant line.
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
New Fleet configuration settings
Summary by CodeRabbit
New Features
Bug Fixes
Documentation