Skip to content

Commit

Permalink
[ignore] Fixed the logical issues for the rules - health_check attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
sajagana authored and lhercot committed Feb 27, 2024
1 parent 132c170 commit 0b3b139
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func resourceMSOSchemaSiteContractServiceGraphListener() *schema.Resource {

// When the Health Checks protocol is "http/https"
newHealthCheckList := newRuleMap["health_check"].(*schema.Set).List()
if len(newHealthCheckList) > 1 {
if len(newHealthCheckList) > 0 {
newHealthCheckMap := newHealthCheckList[0].(interface{}).(map[string]interface{})
newHealthCheckProtocol := newHealthCheckMap["protocol"].(string)
if newHealthCheckProtocol == "http" || newHealthCheckProtocol == "https" {
Expand All @@ -456,6 +456,8 @@ func resourceMSOSchemaSiteContractServiceGraphListener() *schema.Resource {
newHealthCheckHost := newHealthCheckMap["host"].(string)
if !newHealthCheckUseHostFromRule && newHealthCheckHost == "" {
return fmt.Errorf("When the 'health_check' protocol is 'http/https', the 'use_host_from_rule' and 'host' attributes must be set")
} else if newHealthCheckUseHostFromRule && newHealthCheckHost != "" {
return fmt.Errorf("When the 'use_host_from_rule' is true, the 'host' should be empty")
}
}
}
Expand Down Expand Up @@ -978,7 +980,7 @@ func postSchemaSiteContractServiceGraphListenerConfig(ops string, d *schema.Reso
healthCheckPayloadMap["successCode"] = healthCheckMap["success_code"].(string)

healthCheckPayloadMap["useHostFromRule"] = boolToYesNo(healthCheckMap["use_host_from_rule"].(bool))
if healthCheckPayloadMap["useHostFromRule"] == "yes" {
if healthCheckPayloadMap["useHostFromRule"] == "no" {
healthCheckPayloadMap["host"] = healthCheckMap["host"].(string)
}
}
Expand Down

0 comments on commit 0b3b139

Please sign in to comment.