Skip to content

Commit

Permalink
Merge pull request #1158 from citrix/1157-bug-not-able-to-delete-citr…
Browse files Browse the repository at this point in the history
…ixadc_dnssrvrec-resource-and-import-fails-for-some-attributes

Handled deletion and importing operation of dnssrvrec resource
  • Loading branch information
sumanth-lingappa authored May 10, 2024
2 parents 4909910 + de6622e commit 89b6666
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions citrixadc/resource_citrixadc_dnssrvrec.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package citrixadc

import (
"strings"

"github.com/citrix/adc-nitro-go/resource/config/dns"

"github.com/citrix/adc-nitro-go/service"
Expand Down Expand Up @@ -123,13 +125,18 @@ func readDnssrvrecFunc(d *schema.ResourceData, meta interface{}) error {
return nil
}

idSlice := strings.SplitN(dnssrvrecName, ",", 2)

domain := idSlice[0]
target := idSlice[1]

foundIndex := -1
for i, dnssrvrec := range dataArray {
match := true
if dnssrvrec["domain"] != d.Get("domain").(string) {
if dnssrvrec["domain"] != domain {
match = false
}
if dnssrvrec["target"] != d.Get("target").(string) {
if dnssrvrec["target"] != target {
match = false
}
if match {
Expand Down Expand Up @@ -216,12 +223,18 @@ func updateDnssrvrecFunc(d *schema.ResourceData, meta interface{}) error {
func deleteDnssrvrecFunc(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] citrixadc-provider: In deleteDnssrvrecFunc")
client := meta.(*NetScalerNitroClient).client

bindingId := d.Id()
idSlice := strings.SplitN(bindingId, ",", 2)
domain := idSlice[0]
target := idSlice[1]

argsMap := make(map[string]string)
argsMap["target"] = url.QueryEscape(d.Get("target").(string))
argsMap["target"] = url.QueryEscape(target)
if ecs, ok := d.GetOk("ecssubnet"); ok {
argsMap["ecssubnet"] = url.QueryEscape(ecs.(string))
}
err := client.DeleteResourceWithArgsMap(service.Dnssrvrec.Type(), d.Id(), argsMap)
err := client.DeleteResourceWithArgsMap(service.Dnssrvrec.Type(), domain, argsMap)
if err != nil {
return err
}
Expand Down

0 comments on commit 89b6666

Please sign in to comment.