Skip to content

Commit

Permalink
Merge pull request #11 from disc/server-attributes-reordering-on-import
Browse files Browse the repository at this point in the history
Fixed some server's attribute value reordering during importing stage
  • Loading branch information
disc authored Nov 2, 2021
2 parents fcf711c + ad73d46 commit c4e3ed5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions internal/provider/resource_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,12 @@ func resourceReadServer(ctx context.Context, d *schema.ResourceData, meta interf
if !ok {
return diag.Errorf("failed to parse organization_ids for the server: %s", server.Name)
}
d.Set("organization_ids", matchStringEntitiesWithSchema(organizationsList, declaredOrganizations))

if len(declaredOrganizations) > 0 {
organizationsList = matchStringEntitiesWithSchema(organizationsList, declaredOrganizations)
}

d.Set("organization_ids", organizationsList)
}

if len(server.Groups) > 0 {
Expand All @@ -542,15 +547,25 @@ func resourceReadServer(ctx context.Context, d *schema.ResourceData, meta interf
if !ok {
return diag.Errorf("failed to parse groups for the server: %s", server.Name)
}
d.Set("groups", matchStringEntitiesWithSchema(groupsList, declaredGroups))

if len(declaredGroups) > 0 {
groupsList = matchStringEntitiesWithSchema(groupsList, declaredGroups)
}

d.Set("groups", groupsList)
}

if len(routes) > 0 {
declaredRoutes, ok := d.Get("route").([]interface{})
if !ok {
return diag.Errorf("failed to parse routes for the server: %s", server.Name)
}
d.Set("route", flattenRoutesData(matchRoutesWithSchema(routes, declaredRoutes)))

if len(declaredRoutes) > 0 {
routes = matchRoutesWithSchema(routes, declaredRoutes)
}

d.Set("route", flattenRoutesData(routes))
}

if len(hosts) > 0 {
Expand Down

0 comments on commit c4e3ed5

Please sign in to comment.