Skip to content

Commit 0506851

Browse files
ligfxgene-redpanda
authored andcommitted
feat: allow updating cluster name in-place
1 parent e378f2d commit 0506851

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

redpanda/resources/cluster/resource_cluster.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ func resourceClusterSchema() schema.Schema {
8484
return schema.Schema{
8585
Attributes: map[string]schema.Attribute{
8686
"name": schema.StringAttribute{
87-
Required: true,
88-
Description: "Unique name of the cluster.",
89-
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
87+
Required: true,
88+
Description: "Unique name of the cluster.",
9089
},
9190
"cluster_type": schema.StringAttribute{
9291
Required: true,
@@ -405,16 +404,23 @@ func (c *Cluster) Update(ctx context.Context, req resource.UpdateRequest, resp *
405404
var plan models.Cluster
406405
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
407406

407+
var state models.Cluster
408+
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
409+
408410
updateReq := &controlplanev1beta2.UpdateClusterRequest{
409411
Cluster: &controlplanev1beta2.ClusterUpdate{
410-
Id: plan.ID.ValueString(),
411-
Name: plan.Name.ValueString(),
412+
Id: plan.ID.ValueString(),
412413
},
413414
UpdateMask: &fieldmaskpb.FieldMask{
414415
Paths: make([]string, 0),
415416
},
416417
}
417418

419+
if !plan.Name.Equal(state.Name) {
420+
updateReq.Cluster.Name = plan.Name.ValueString()
421+
updateReq.UpdateMask.Paths = append(updateReq.UpdateMask.Paths, "name")
422+
}
423+
418424
if !isAwsPrivateLinkStructNil(plan.AwsPrivateLink) {
419425
updateReq.Cluster.AwsPrivateLink = &controlplanev1beta2.AWSPrivateLinkSpec{
420426
Enabled: plan.AwsPrivateLink.Enabled.ValueBool(),

0 commit comments

Comments
 (0)