Skip to content

Commit 19c47ce

Browse files
committed
modifed node info validation for member
1 parent c953334 commit 19c47ce

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

internal/service/grid/member_resource.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,16 @@ func (r *MemberResource) ValidateConfig(ctx context.Context, req resource.Valida
558558
}
559559

560560
if len(nodeInfo) == 2 {
561-
if data.EnableHa.IsNull() || data.EnableHa.IsUnknown() || !data.EnableHa.ValueBool() {
562-
resp.Diagnostics.AddError("Validation Error", "enable_ha must be true when node_info contains 2 nodes")
563-
}
564-
}
561+
if data.EnableHa.IsNull() || data.EnableHa.IsUnknown() || !data.EnableHa.ValueBool() {
562+
resp.Diagnostics.AddError("Validation Error", "node_info contains 2 nodes but enable_ha is not set to true. Either set enable_ha = true to enable HA mode, or configure only a single node in node_info when enable_ha is false")
563+
}
564+
} else if len(nodeInfo) > 2 {
565+
if !data.EnableHa.IsNull() && !data.EnableHa.IsUnknown() && data.EnableHa.ValueBool() {
566+
resp.Diagnostics.AddError("Validation Error", "node_info must contain exactly 2 nodes when enable_ha is true")
567+
} else {
568+
resp.Diagnostics.AddError("Validation Error", "node_info must contain 1 node when enable_ha is false")
569+
}
570+
}
565571
}
566572

567573
if !data.MgmtPortSetting.IsNull() && !data.MgmtPortSetting.IsUnknown() {

0 commit comments

Comments
 (0)