Skip to content

Conversation

@tobio
Copy link
Member

@tobio tobio commented Dec 16, 2025

Related to #1553

This PR also fixes up the import pathway for agent policies that do not exist in the default space.

@tobio tobio requested a review from dimuon December 16, 2025 03:33
@tobio tobio self-assigned this Dec 16, 2025
Copilot AI review requested due to automatic review settings December 16, 2025 03:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds acceptance testing for agent policies created in non-default Kibana spaces and fixes the import pathway to support space-scoped agent policies. The changes address issue #1553 by ensuring agent policies can be properly imported with their associated space ID.

Key Changes:

  • Added acceptance test TestAccResourceAgentPolicyNonDefaultSpace verifying agent policy creation and import in non-default spaces
  • Updated ImportState method to parse composite IDs containing space and policy IDs
  • Updated documentation to reflect the new import syntax supporting space-scoped imports

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/fleet/agent_policy/testdata/TestAccResourceAgentPolicyNonDefaultSpace/create/variables.tf Defines test variables for policy name, space ID, and space name
internal/fleet/agent_policy/testdata/TestAccResourceAgentPolicyNonDefaultSpace/create/main.tf Test configuration creating a Kibana space and agent policy in that space
internal/fleet/agent_policy/resource.go Enhanced ImportState to handle composite IDs with space information
internal/fleet/agent_policy/acc_test.go Added acceptance test verifying agent policy creation and import in non-default spaces
examples/resources/elasticstack_fleet_agent_policy/import.sh Updated import example to show space_id/policy_id format
docs/resources/fleet_agent_policy.md Updated documentation to reflect new import syntax

compID, diags := clients.CompositeIdFromStrFw(req.ID)
if diags.HasError() {
policyID = req.ID
} else {
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The field name ClusterId is misleading in this context as it's being used to store a spaceID, not a cluster ID. Consider using a more appropriate field or adding a comment explaining this usage.

Suggested change
} else {
} else {
// Note: compID.ClusterId is used here to store the space ID, not a cluster ID.

Copilot uses AI. Check for mistakes.
@tobio tobio merged commit b7ebf7a into main Dec 16, 2025
54 checks passed
@tobio tobio deleted the non-default-space-agent-policy branch December 16, 2025 10:55
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.

3 participants