From d7b3d9942cc6e6e70a8be6e0542c1693de2bfd78 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 23 Dec 2024 12:28:25 -0500 Subject: [PATCH] Fixes for the Team Resource (#93) * Bugfix: ensure Team Name is read when refreshing State * Bugfix: Ensure planned Team Name is included in Updates * Enhancement: Require replacement if Team Name changes --- internal/provider/team_resource.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/provider/team_resource.go b/internal/provider/team_resource.go index 177123c..55b3250 100644 --- a/internal/provider/team_resource.go +++ b/internal/provider/team_resource.go @@ -73,6 +73,9 @@ func (r *TeamResource) Schema(ctx context.Context, req resource.SchemaRequest, r "name": schema.StringAttribute{ Required: true, Description: "Team name", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, }, "manage_state": schema.BoolAttribute{ Optional: true, @@ -271,6 +274,7 @@ func (r *TeamResource) Read(ctx context.Context, req resource.ReadRequest, resp tflog.Info(ctx, "Body Response", map[string]any{"bodyResponse": string(bodyResponse)}) + state.Name = types.StringValue(team.Name) state.ManageState = types.BoolValue(team.ManageState) state.ManageWorkspace = types.BoolValue(team.ManageWorkspace) state.ManageModule = types.BoolValue(team.ManageModule) @@ -372,7 +376,7 @@ func (r *TeamResource) Update(ctx context.Context, req resource.UpdateRequest, r } plan.ID = types.StringValue(state.ID.ValueString()) - plan.Name = types.StringValue(state.Name.ValueString()) + plan.Name = types.StringValue(team.Name) plan.ManageState = types.BoolValue(team.ManageState) plan.ManageWorkspace = types.BoolValue(team.ManageWorkspace) plan.ManageModule = types.BoolValue(team.ManageModule)