Skip to content

Commit

Permalink
Merge pull request #1463 from vmware/fix-lb-empty-block
Browse files Browse the repository at this point in the history
Fix crash related to empty block in lb_vs resource
  • Loading branch information
annakhm authored Dec 9, 2024
2 parents 35f6088 + 5f755b8 commit e126f93
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions nsxt/resource_nsxt_policy_lb_virtual_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,10 @@ func getPolicyLbRuleVariablePersistenceLearnActionSchema() *schema.Schema {
func getPolicyClientSSLBindingFromSchema(d *schema.ResourceData) *model.LBClientSslProfileBinding {
bindings := d.Get("client_ssl").([]interface{})
for _, binding := range bindings {
if binding == nil {
// empty clause
continue
}
// maximum count is one
data := binding.(map[string]interface{})
chainDepth := int64(data["certificate_chain_depth"].(int))
Expand Down Expand Up @@ -958,6 +962,10 @@ func setPolicyClientSSLBindingInSchema(d *schema.ResourceData, binding *model.LB
func getPolicyServerSSLBindingFromSchema(d *schema.ResourceData) *model.LBServerSslProfileBinding {
bindings := d.Get("server_ssl").([]interface{})
for _, binding := range bindings {
if binding == nil {
// empty clause
continue
}
// maximum count is one
data := binding.(map[string]interface{})
chainDepth := int64(data["certificate_chain_depth"].(int))
Expand Down Expand Up @@ -1402,6 +1410,10 @@ func getPolicyLbRulesFromSchema(d *schema.ResourceData) []model.LBRule {
rules := d.Get("rule").([]interface{})

for _, rule := range rules {
if rule == nil {
// empty clause
continue
}
ruleData := rule.(map[string]interface{})

displayName := ruleData["display_name"].(string)
Expand All @@ -1412,6 +1424,10 @@ func getPolicyLbRulesFromSchema(d *schema.ResourceData) []model.LBRule {

ruleActions := ruleData["action"]
for _, ruleAction := range ruleActions.([]interface{}) {
if ruleAction == nil {
// empty clause
continue
}

ruleAction := ruleAction.(map[string]interface{})

Expand Down Expand Up @@ -1474,6 +1490,10 @@ func getPolicyLbRulesFromSchema(d *schema.ResourceData) []model.LBRule {

ruleConditions := ruleData["condition"]
for _, ruleCondition := range ruleConditions.([]interface{}) {
if ruleCondition == nil {
// empty clause
continue
}

ruleCondition := ruleCondition.(map[string]interface{})

Expand Down

0 comments on commit e126f93

Please sign in to comment.