Skip to content

Commit

Permalink
[bugfix] Fix read and import for mso_schema_site_anp resource to sele…
Browse files Browse the repository at this point in the history
…ct anp in correct site and template combination
  • Loading branch information
akinross authored and lhercot committed Oct 17, 2024
1 parent f974b5f commit 40585d8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions mso/resource_mso_schema_site_anp.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,17 @@ func resourceMSOSchemaSiteAnpImport(d *schema.ResourceData, m interface{}) ([]*s
return nil, fmt.Errorf("No Sites found")
}
stateSite := get_attribute[2]
stateTemplate := get_attribute[4]
found := false
stateAnp := get_attribute[4]
stateAnp := get_attribute[6]
for i := 0; i < count; i++ {
tempCont, err := cont.ArrayElement(i, "sites")
if err != nil {
return nil, err
}
apiSite := models.StripQuotes(tempCont.S("siteId").String())

if apiSite == stateSite {
apiTemplate := models.StripQuotes(tempCont.S("templateName").String())
if apiSite == stateSite && apiTemplate == stateTemplate {

anpCount, err := tempCont.ArrayCount("anps")
if err != nil {
Expand Down Expand Up @@ -171,6 +172,7 @@ func resourceMSOSchemaSiteAnpRead(d *schema.ResourceData, m interface{}) error {
return fmt.Errorf("No Sites found")
}
stateSite := d.Get("site_id").(string)
stateTemplate := d.Get("template_name").(string)
found := false
stateAnp := d.Get("anp_name").(string)
for i := 0; i < count; i++ {
Expand All @@ -179,8 +181,9 @@ func resourceMSOSchemaSiteAnpRead(d *schema.ResourceData, m interface{}) error {
return err
}
apiSite := models.StripQuotes(tempCont.S("siteId").String())
apiTemplate := models.StripQuotes(tempCont.S("templateName").String())

if apiSite == stateSite {
if apiSite == stateSite && apiTemplate == stateTemplate {
anpCount, err := tempCont.ArrayCount("anps")
if err != nil {
return fmt.Errorf("Unable to get Anp list")
Expand Down

0 comments on commit 40585d8

Please sign in to comment.