Skip to content

Commit

Permalink
Merge pull request #54 from Freeaqingme/fix51
Browse files Browse the repository at this point in the history
Bugfix: Store Redirect sources and destinations in statefile (closes #51)
  • Loading branch information
mbardelmeijer authored May 14, 2024
2 parents a48fc41 + a570f60 commit 82bc536
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions internal/provider/resource_redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,19 @@ func resourceRedirectRead(ctx context.Context, d *schema.ResourceData, meta any)
}

d.SetId(d.Id())
for i, dst := range respData.Data.Destinations {
d.Set(fmt.Sprintf("destination.%d.url", i), dst.Url)
d.Set(fmt.Sprintf("destination.%d.expression", i), dst.Expression)
d.Set(fmt.Sprintf("destination.%d.monitoring", i), dst.Monitoring)
destinations := []map[string]string{}
for _, dst := range respData.Data.Destinations {
destinations = append(destinations, map[string]string{
"url": dst.Url,
"expression": dst.Expression,
"monitoring": dst.Monitoring,
})
}
d.Set("destination", destinations)

sources := make([]interface{}, len(respData.Data.Sources), len(respData.Data.Sources))
for i, src := range respData.Data.Sources {
source := map[string]interface{}{
"url": src.Url,
}
sources[i] = source
sources := []string{}
for _, src := range respData.Data.Sources {
sources = append(sources, src.Url)
}
d.Set("sources", sources)
d.Set("redirect_type", respData.Data.RedirectType)
Expand Down

0 comments on commit 82bc536

Please sign in to comment.