File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ type Client struct {
51
51
K6APIConfig * k6providerapi.K6APIConfig
52
52
53
53
alertingMutex sync.Mutex
54
+ folderMutex sync.Mutex
54
55
}
55
56
56
57
// WithAlertingMutex is a helper function that wraps a CRUD Terraform function with a mutex.
@@ -63,6 +64,16 @@ func WithAlertingMutex[T schema.CreateContextFunc | schema.ReadContextFunc | sch
63
64
}
64
65
}
65
66
67
+ // WithFolderMutex is a helper function that wraps a CRUD Terraform function with a mutex.
68
+ func WithFolderMutex [T schema.CreateContextFunc | schema.ReadContextFunc | schema.UpdateContextFunc | schema.DeleteContextFunc ](f T ) T {
69
+ return func (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
70
+ lock := & meta .(* Client ).folderMutex
71
+ lock .Lock ()
72
+ defer lock .Unlock ()
73
+ return f (ctx , d , meta )
74
+ }
75
+ }
76
+
66
77
func (c * Client ) GrafanaSubpath (path string ) string {
67
78
path = strings .TrimPrefix (path , c .GrafanaAPIURLParsed .Path )
68
79
return c .GrafanaAPIURLParsed .JoinPath (path ).String ()
Original file line number Diff line number Diff line change @@ -29,10 +29,10 @@ func resourceFolder() *common.Resource {
29
29
* [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/folder/)
30
30
` ,
31
31
32
- CreateContext : CreateFolder ,
33
- DeleteContext : DeleteFolder ,
32
+ CreateContext : common. WithFolderMutex [schema. CreateContextFunc ]( CreateFolder ) ,
33
+ DeleteContext : common. WithFolderMutex [schema. DeleteContextFunc ]( DeleteFolder ) ,
34
34
ReadContext : ReadFolder ,
35
- UpdateContext : UpdateFolder ,
35
+ UpdateContext : common. WithFolderMutex [schema. UpdateContextFunc ]( UpdateFolder ) ,
36
36
Importer : & schema.ResourceImporter {
37
37
StateContext : schema .ImportStatePassthroughContext ,
38
38
},
You can’t perform that action at this time.
0 commit comments