Skip to content

Commit a9310c0

Browse files
committed
Use existing util
1 parent d2aa685 commit a9310c0

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

internal/elasticsearch/index/index/update.go

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package index
22

33
import (
44
"context"
5-
"reflect"
65

76
"github.com/elastic/terraform-provider-elasticstack/internal/clients"
87
"github.com/elastic/terraform-provider-elasticstack/internal/clients/elasticsearch"
98
"github.com/elastic/terraform-provider-elasticstack/internal/diagutil"
109
"github.com/elastic/terraform-provider-elasticstack/internal/models"
10+
"github.com/elastic/terraform-provider-elasticstack/internal/utils"
1111
"github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes"
1212
"github.com/hashicorp/terraform-plugin-framework/diag"
1313
"github.com/hashicorp/terraform-plugin-framework/resource"
@@ -115,7 +115,7 @@ func (r *Resource) updateSettings(ctx context.Context, client *clients.ApiClient
115115
}
116116
}
117117

118-
if !deepEqual(planDynamicSettings, stateDynamicSettings) {
118+
if !utils.MapsEqual(planDynamicSettings, stateDynamicSettings) {
119119
// Settings which are being removed must be explicitly set to null in the new settings
120120
for setting := range stateDynamicSettings {
121121
if _, ok := planDynamicSettings[setting]; !ok {
@@ -149,24 +149,3 @@ func (r *Resource) updateMappings(ctx context.Context, client *clients.ApiClient
149149

150150
return nil
151151
}
152-
153-
// deepEqual compares two maps for deep equality, handling slices and other types
154-
// that are not comparable with maps.Equal
155-
func deepEqual(a, b map[string]interface{}) bool {
156-
if len(a) != len(b) {
157-
return false
158-
}
159-
160-
for key, valueA := range a {
161-
valueB, exists := b[key]
162-
if !exists {
163-
return false
164-
}
165-
166-
if !reflect.DeepEqual(valueA, valueB) {
167-
return false
168-
}
169-
}
170-
171-
return true
172-
}

0 commit comments

Comments
 (0)