Skip to content

Commit

Permalink
Merge pull request #7 from SamuZad/feat/aliases-sort
Browse files Browse the repository at this point in the history
sort aliases and implement diffsuppress
  • Loading branch information
SamuZad authored May 11, 2024
2 parents 1aa5247 + 618ae2b commit 437bba9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions internal/provider/resource_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"net/mail"
"reflect"
"sort"
"strconv"
"time"

Expand Down Expand Up @@ -47,6 +48,18 @@ func diffSuppressEmails(k, old, new string, d *schema.ResourceData) bool {
return reflect.DeepEqual(subsetEmails, configEmails.([]interface{}))
}

func diffSuppressAliases(k, old, new string, d *schema.ResourceData) bool {
stateAliases, configAliases := d.GetChange("aliases")

stateList := listOfInterfacestoStrings(stateAliases.([]interface{}))
configList := listOfInterfacestoStrings(configAliases.([]interface{}))

sort.Strings(stateList)
sort.Strings(configList)

return reflect.DeepEqual(stateList, configList)
}

func diffSuppressCustomSchemas(_, _, _ string, d *schema.ResourceData) bool {
old, new := d.GetChange("custom_schemas")
customSchemasOld := old.([]interface{})
Expand Down Expand Up @@ -352,9 +365,10 @@ func resourceUser() *schema.Resource {
},
},
"aliases": {
Description: "asps.list of the user's alias email addresses.",
Type: schema.TypeList,
Optional: true,
Description: "asps.list of the user's alias email addresses.",
Type: schema.TypeList,
Optional: true,
DiffSuppressFunc: diffSuppressAliases,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand Down

0 comments on commit 437bba9

Please sign in to comment.