Skip to content

Commit 576b084

Browse files
authored
Merge pull request #200 from pkalemba/master
[Iploadbalancing] Do not search when service_name was passed
2 parents b4044e6 + 9a53857 commit 576b084

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ovh/data_source_ovh_iploadbalancing.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,18 @@ func dataSourceIpLoadbalancing() *schema.Resource {
139139

140140
func dataSourceIpLoadbalancingRead(d *schema.ResourceData, meta interface{}) error {
141141
config := meta.(*Config)
142-
log.Printf("[DEBUG] Will list available iploadbalancing services")
143142

144143
response := []string{}
145-
err := config.OVHClient.Get("/ipLoadbalancing", &response)
146-
147-
if err != nil {
148-
return fmt.Errorf("Error calling /ipLoadbalancing:\n\t %q", err)
144+
v, exists := d.GetOk("service_name")
145+
if exists {
146+
log.Printf("[DEBUG] Will use provided iploadbalancing service")
147+
response = append(response, v.(string))
148+
} else {
149+
log.Printf("[DEBUG] Will list available iploadbalancing services")
150+
err := config.OVHClient.Get("/ipLoadbalancing", &response)
151+
if err != nil {
152+
return fmt.Errorf("Error calling /ipLoadbalancing:\n\t %q", err)
153+
}
149154
}
150155

151156
filtered_iplbs := []*IpLoadbalancing{}

0 commit comments

Comments
 (0)