Skip to content

Commit 4486fdf

Browse files
Merge pull request #517 from F5Networks/devel
updated as3 resource to fix tenant_filter issue
2 parents 3f9cbd2 + 263a63f commit 4486fdf

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

bigip/resource_bigip_as3.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ func resourceBigipAs3Create(d *schema.ResourceData, meta interface{}) error {
169169
tenantList, _, applicationList := client.GetTenantList(as3Json)
170170
tenantCount := strings.Split(tenantList, ",")
171171
if tenantFilter != "" {
172+
log.Printf("[DEBUG] tenantFilter:%+v", tenantFilter)
173+
if !contains(tenantCount, tenantFilter) {
174+
return fmt.Errorf("tenant_filter: (%s) not exist in as3_json provided ", tenantFilter)
175+
}
172176
tenantList = tenantFilter
173177
}
174178
_ = d.Set("tenant_list", tenantList)
@@ -253,7 +257,11 @@ func resourceBigipAs3Exists(d *schema.ResourceData, meta interface{}) (bool, err
253257
applicationList := d.Get("application_list").(string)
254258
tenantFilter := d.Get("tenant_filter").(string)
255259
if tenantFilter != "" {
256-
name = tenantFilter
260+
if !contains(strings.Split(name, ","), tenantFilter) {
261+
log.Printf("[WARNING]tenant_filter: (%s) not exist in as3_json provided ", tenantFilter)
262+
} else {
263+
name = tenantFilter
264+
}
257265
}
258266
as3Resp, err := client.GetAs3(name, applicationList)
259267
if err != nil {
@@ -299,7 +307,11 @@ func resourceBigipAs3Update(d *schema.ResourceData, meta interface{}) error {
299307
}
300308
}
301309
} else {
302-
tenantList = tenantFilter
310+
if !contains(strings.Split(tenantList, ","), tenantFilter) {
311+
log.Printf("[WARNING]tenant_filter: (%s) not exist in as3_json provided ", tenantFilter)
312+
} else {
313+
tenantList = tenantFilter
314+
}
303315
}
304316
strTrimSpace, err := client.AddTeemAgent(as3Json)
305317
if err != nil {
@@ -343,3 +355,12 @@ func resourceBigipAs3Delete(d *schema.ResourceData, meta interface{}) error {
343355
d.SetId("")
344356
return nil
345357
}
358+
359+
func contains(s []string, str string) bool {
360+
for _, v := range s {
361+
if v == str {
362+
return true
363+
}
364+
}
365+
return false
366+
}

bigip/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package bigip
22

33
// ProviderVersion is set at build-time in the release process
4-
var ProviderVersion = "1.9.0"
4+
var ProviderVersion = "1.10.0"

0 commit comments

Comments
 (0)