Skip to content

Commit

Permalink
fix: setting listener policy rule values
Browse files Browse the repository at this point in the history
  • Loading branch information
deepaksibm authored and hkantare committed Aug 19, 2021
1 parent b4825f4 commit 3bd1fa9
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions ibm/resource_ibm_is_lb_listener_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,10 +841,31 @@ func lbListenerPolicyGet(d *schema.ResourceData, meta interface{}, lbID, listene
if policy.Rules != nil {
policyRules := policy.Rules
rulesInfo := make([]map[string]interface{}, 0)
for _, index := range policyRules {
for _, policyRuleItem := range policyRules {
ruleId := *policyRuleItem.ID
getLbListenerPolicyRuleOptions := &vpcv1.GetLoadBalancerListenerPolicyRuleOptions{
LoadBalancerID: &lbID,
ListenerID: &listenerID,
PolicyID: &id,
ID: &ruleId,
}

//Getting lb listener policy rule
rule, response, err := sess.GetLoadBalancerListenerPolicyRule(getLbListenerPolicyRuleOptions)
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
return nil
}
return err
}

l := map[string]interface{}{
isLBListenerPolicyRuleID: index.ID,
isLBListenerPolicyRuleCondition: rule.Condition,
isLBListenerPolicyRuleType: rule.Type,
isLBListenerPolicyRuleField: rule.Field,
isLBListenerPolicyRuleValue: rule.Value,
isLBListenerPolicyRuleID: rule.ID,
}
rulesInfo = append(rulesInfo, l)
}
Expand Down

0 comments on commit 3bd1fa9

Please sign in to comment.