Skip to content

Commit

Permalink
Fixes #10 - Random reordering for server's attribute during the impor…
Browse files Browse the repository at this point in the history
…ting step because there is no previous (or setup in advance) state
  • Loading branch information
disc committed Nov 2, 2021
1 parent 6d48d7e commit ad73d46
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 ad73d46

Please sign in to comment.