@@ -239,15 +239,13 @@ func (r *GrafanaLibraryPanelReconciler) finalize(ctx context.Context, libraryPan
239
239
log := logf .FromContext (ctx )
240
240
log .Info ("Finalizing GrafanaLibraryPanel" )
241
241
242
- uid := content .CustomUIDOrUID (libraryPanel , libraryPanel .Status .UID )
243
-
244
242
instances , err := GetScopedMatchingInstances (ctx , r .Client , libraryPanel )
245
243
if err != nil {
246
244
return fmt .Errorf ("fetching instances: %w" , err )
247
245
}
248
246
249
247
for _ , instance := range instances {
250
- found , _ := instance .Status .LibraryPanels .Find (libraryPanel .Namespace , libraryPanel .Name )
248
+ found , uid := instance .Status .LibraryPanels .Find (libraryPanel .Namespace , libraryPanel .Name )
251
249
if ! found {
252
250
log .Info ("librarypanel not found on instance - skipping finalize" , "grafana" , instance .Name , "uid" , uid )
253
251
continue
@@ -260,7 +258,7 @@ func (r *GrafanaLibraryPanelReconciler) finalize(ctx context.Context, libraryPan
260
258
261
259
isCleanupInGrafanaRequired := true
262
260
263
- resp , err := grafanaClient .LibraryElements .GetLibraryElementConnections (uid )
261
+ resp , err := grafanaClient .LibraryElements .GetLibraryElementConnections (* uid )
264
262
if err != nil {
265
263
var notFound * library_elements.GetLibraryElementConnectionsNotFound
266
264
if ! errors .As (err , & notFound ) {
@@ -273,10 +271,10 @@ func (r *GrafanaLibraryPanelReconciler) finalize(ctx context.Context, libraryPan
273
271
// Skip cleanup in instances
274
272
if isCleanupInGrafanaRequired {
275
273
if len (resp .Payload .Result ) > 0 {
276
- return fmt .Errorf ("library panel %s/%s/%s on instance %s/%s has existing connections" , libraryPanel .Namespace , libraryPanel .Name , uid , instance .Namespace , instance .Name ) //nolint
274
+ return fmt .Errorf ("library panel %s/%s/%s on instance %s/%s has existing connections" , libraryPanel .Namespace , libraryPanel .Name , * uid , instance .Namespace , instance .Name ) //nolint
277
275
}
278
276
279
- _ , err = grafanaClient .LibraryElements .DeleteLibraryElementByUID (uid ) //nolint:errcheck
277
+ _ , err = grafanaClient .LibraryElements .DeleteLibraryElementByUID (* uid ) //nolint:errcheck
280
278
if err != nil {
281
279
var notFound * library_elements.DeleteLibraryElementByUIDNotFound
282
280
if ! errors .As (err , & notFound ) {
0 commit comments