Skip to content

Commit 9854819

Browse files
committed
pull in sysMonitoring update
1 parent cfd515e commit 9854819

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

internal/clients/fleet/fleet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func ReadAgentPolicy(ctx context.Context, client *Client, id string) (*fleetapi.
6666
}
6767

6868
// CreateAgentPolicy creates a new agent policy.
69-
func CreateAgentPolicy(ctx context.Context, client *Client, req fleetapi.AgentPolicyCreateRequest, sysMonitoring bool) (*fleetapi.AgentPolicy, diag.Diagnostics) {
69+
func CreateAgentPolicy(ctx context.Context, client *Client, req fleetapi.AgentPolicyCreateRequest, sysMonitoring bool) (*fleetapi.AgentPolicy, fwdiag.Diagnostics) {
7070
resp, err := client.API.CreateAgentPolicyWithResponse(ctx, req, func(ctx context.Context, req *http.Request) error {
7171
if sysMonitoring {
7272
qs := req.URL.Query()

internal/fleet/agent_policy/create.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ func (r *agentPolicyResource) Create(ctx context.Context, req resource.CreateReq
2323
}
2424

2525
body := planModel.toAPICreateModel()
26-
policy, diags := fleet.CreateAgentPolicy(ctx, client, body)
26+
27+
sysMonitoring := planModel.SysMonitoring.ValueBool()
28+
policy, diags := fleet.CreateAgentPolicy(ctx, client, body, sysMonitoring)
2729
resp.Diagnostics.Append(diags...)
2830
if resp.Diagnostics.HasError() {
2931
return

internal/fleet/agent_policy/schema.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/hashicorp/terraform-plugin-framework/resource"
77
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
8+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
89
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
910
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1011
)
@@ -66,10 +67,12 @@ func (r *agentPolicyResource) Schema(ctx context.Context, req resource.SchemaReq
6667
Description: "Set to true if you do not wish the agent policy to be deleted at destroy time, and instead just remove the agent policy from the Terraform state.",
6768
Optional: true,
6869
},
69-
// This was never used, kept for compatibility
7070
"sys_monitoring": schema.BoolAttribute{
7171
Description: "Enable collection of system logs and metrics.",
7272
Optional: true,
73+
PlanModifiers: []planmodifier.Bool{
74+
boolplanmodifier.RequiresReplace(),
75+
},
7376
},
7477
}
7578
}

0 commit comments

Comments
 (0)