Skip to content

Commit 43f6458

Browse files
committed
validate that cluster's project id stays constant
1 parent 7494031 commit 43f6458

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/resource/cluster.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,18 @@ func (r *clusterResource) Read(ctx context.Context, req resource.ReadRequest, re
110110
}
111111

112112
func (r *clusterResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
113-
var data cluster
113+
var data, state cluster
114114
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
115+
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
115116
if resp.Diagnostics.HasError() {
116117
return
117118
}
118119

120+
if !data.ProjectId.Equal(state.ProjectId) {
121+
resp.Diagnostics.AddError("Invalid Configuration", fmt.Sprintf("Unable to update cluster, project ID must not be modified"))
122+
return
123+
}
124+
119125
_, err := r.client.UpdateCluster(ctx, data.Id.ValueString(), data.UpdateAttributes(ctx, resp.Diagnostics))
120126
if err != nil {
121127
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update cluster, got error: %s", err))

0 commit comments

Comments
 (0)