File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
internal/resources/grafana Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,16 @@ Manages Grafana dashboards.
38
38
StateContext : schema .ImportStatePassthroughContext ,
39
39
},
40
40
41
+ CustomizeDiff : func (ctx context.Context , d * schema.ResourceDiff , meta interface {}) error {
42
+ oldVal , newVal := d .GetChange ("config_json" )
43
+ oldUID := extractUID (oldVal .(string ))
44
+ newUID := extractUID (newVal .(string ))
45
+ if oldUID != newUID {
46
+ d .ForceNew ("config_json" )
47
+ }
48
+ return nil
49
+ },
50
+
41
51
Schema : map [string ]* schema.Schema {
42
52
"org_id" : orgIDAttribute (),
43
53
"uid" : {
@@ -301,3 +311,14 @@ func NormalizeDashboardConfigJSON(config interface{}) string {
301
311
return string (j )
302
312
}
303
313
}
314
+
315
+ func extractUID (jsonStr string ) string {
316
+ var parsed map [string ]interface {}
317
+ if err := json .Unmarshal ([]byte (jsonStr ), & parsed ); err != nil {
318
+ return ""
319
+ }
320
+ if uid , ok := parsed ["uid" ].(string ); ok {
321
+ return uid
322
+ }
323
+ return ""
324
+ }
You can’t perform that action at this time.
0 commit comments