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 {
5151 K6APIConfig * k6providerapi.K6APIConfig
5252
5353 alertingMutex sync.Mutex
54+ folderMutex sync.Mutex
5455}
5556
5657// 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
6364 }
6465}
6566
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+
6677func (c * Client ) GrafanaSubpath (path string ) string {
6778 path = strings .TrimPrefix (path , c .GrafanaAPIURLParsed .Path )
6879 return c .GrafanaAPIURLParsed .JoinPath (path ).String ()
Original file line number Diff line number Diff line change @@ -29,10 +29,10 @@ func resourceFolder() *common.Resource {
2929* [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/folder/)
3030` ,
3131
32- CreateContext : CreateFolder ,
33- DeleteContext : DeleteFolder ,
32+ CreateContext : common. WithFolderMutex [schema. CreateContextFunc ]( CreateFolder ) ,
33+ DeleteContext : common. WithFolderMutex [schema. DeleteContextFunc ]( DeleteFolder ) ,
3434 ReadContext : ReadFolder ,
35- UpdateContext : UpdateFolder ,
35+ UpdateContext : common. WithFolderMutex [schema. UpdateContextFunc ]( UpdateFolder ) ,
3636 Importer : & schema.ResourceImporter {
3737 StateContext : schema .ImportStatePassthroughContext ,
3838 },
You can’t perform that action at this time.
0 commit comments