File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,9 @@ type Client struct {
5050 K6APIClient * k6.APIClient
5151 K6APIConfig * k6providerapi.K6APIConfig
5252
53- alertingMutex sync.Mutex
54- folderMutex sync.Mutex
53+ alertingMutex sync.Mutex
54+ folderMutex sync.Mutex
55+ dashboardMutex sync.Mutex
5556}
5657
5758// WithAlertingMutex is a helper function that wraps a CRUD Terraform function with a mutex.
@@ -74,6 +75,16 @@ func WithFolderMutex[T schema.CreateContextFunc | schema.ReadContextFunc | schem
7475 }
7576}
7677
78+ // WithDashboardMutex is a helper function that wraps a CRUD Terraform function with a mutex.
79+ func WithDashboardMutex [T schema.CreateContextFunc | schema.ReadContextFunc | schema.UpdateContextFunc | schema.DeleteContextFunc ](f T ) T {
80+ return func (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
81+ lock := & meta .(* Client ).dashboardMutex
82+ lock .Lock ()
83+ defer lock .Unlock ()
84+ return f (ctx , d , meta )
85+ }
86+ }
87+
7788func (c * Client ) GrafanaSubpath (path string ) string {
7889 path = strings .TrimPrefix (path , c .GrafanaAPIURLParsed .Path )
7990 return c .GrafanaAPIURLParsed .JoinPath (path ).String ()
Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ Manages Grafana dashboards.
3030* [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/dashboard/)
3131` ,
3232
33- CreateContext : CreateDashboard ,
33+ CreateContext : common. WithDashboardMutex [schema. CreateContextFunc ]( CreateDashboard ) ,
3434 ReadContext : ReadDashboard ,
35- UpdateContext : UpdateDashboard ,
36- DeleteContext : DeleteDashboard ,
35+ UpdateContext : common. WithDashboardMutex [schema. UpdateContextFunc ]( UpdateDashboard ) ,
36+ DeleteContext : common. WithDashboardMutex [schema. DeleteContextFunc ]( DeleteDashboard ) ,
3737 Importer : & schema.ResourceImporter {
3838 StateContext : schema .ImportStatePassthroughContext ,
3939 },
You can’t perform that action at this time.
0 commit comments