Skip to content

Commit

Permalink
cleanup diff method
Browse files Browse the repository at this point in the history
  • Loading branch information
smashi committed Jun 1, 2023
1 parent 482412c commit 7ade938
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions myrasec/resource_myrasec_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,24 +379,20 @@ func resourceMyrasecSettings() *schema.Resource {
}

func resourceCustomizeDiff(ctx context.Context, d *schema.ResourceDiff, m interface{}) error {
currentlySetAttributes := d.Get("available_attributes").(*schema.Set)
availableAttributes := []string{}

availableAttribtues := []string{}
resource := resourceMyrasecSettings()
for name, attr := range resource.Schema {
if attr.Type == schema.TypeBool {
notSet := d.GetRawConfig().GetAttr(name).IsNull()

inList := isInList(name, currentlySetAttributes.List())
if (inList && !notSet) || (!notSet && !inList) {
availableAttribtues = append(availableAttribtues, name)
} else {
log.Println("not in list")
if !notSet {
availableAttributes = append(availableAttributes, name)
}
}
}

d.SetNew("available_attributes", availableAttribtues)
d.SetNew("available_attributes", availableAttributes)

return nil
}
Expand Down

0 comments on commit 7ade938

Please sign in to comment.