summaryrefslogtreecommitdiff
path: root/internal/provider
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/provider/identity_resource.go9
-rw-r--r--internal/provider/utils.go17
2 files changed, 25 insertions, 1 deletions
diff --git a/internal/provider/identity_resource.go b/internal/provider/identity_resource.go
index 8804f54..4df4219 100644
--- a/internal/provider/identity_resource.go
+++ b/internal/provider/identity_resource.go
@@ -143,7 +143,14 @@ func (r *IdentityResource) Read(ctx context.Context, req resource.ReadRequest, r
data.Connector = types.StringValue(identity.Connector)
data.Id = types.StringValue(identity.Id.String())
data.Name = types.StringValue(identity.Name)
- data.RawData = types.StringValue(string(identity.RawData))
+ rawDataEquals, err := JSONRawDataEqual(identity.RawData, json.RawMessage(data.RawData.ValueString()))
+ if err != nil {
+ resp.Diagnostics.AddError("JSONRawDataequal", fmt.Sprintf("Unable to compare identities RawData, got error: %s", err))
+ return
+ }
+ if !rawDataEquals {
+ data.RawData = types.StringValue(string(identity.RawData))
+ }
data.Status = types.StringValue(string(identity.Status))
data.Type = types.StringValue(identity.Type)
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
diff --git a/internal/provider/utils.go b/internal/provider/utils.go
new file mode 100644
index 0000000..3b1b665
--- /dev/null
+++ b/internal/provider/utils.go
@@ -0,0 +1,17 @@
+package provider
+
+import (
+ "encoding/json"
+ "reflect"
+)
+
+func JSONRawDataEqual(a, b json.RawMessage) (bool, error) {
+ var j, j2 interface{}
+ if err := json.Unmarshal([]byte(a), &j); err != nil {
+ return false, err
+ }
+ if err := json.Unmarshal([]byte(b), &j2); err != nil {
+ return false, err
+ }
+ return reflect.DeepEqual(j2, j), nil
+}