Chore: Upgrade k8s.io/api v0.34.1 and grafana-app-sdk v0.43.1 (#111009)

This commit is contained in:
Ryan McKinley
2025-09-16 13:35:20 +03:00
committed by GitHub
parent c251ebf4d5
commit 0a79b3bdc5
142 changed files with 4404 additions and 2627 deletions
+22 -19
View File
@@ -1,16 +1,17 @@
package rest
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/klog/v2"
"github.com/grafana/grafana/pkg/apimachinery/utils"
)
// Function that will create a dual writer
@@ -162,27 +163,29 @@ func SetDualWritingMode(
return cfg.Mode, nil
}
var defaultConverter = runtime.UnstructuredConverter(runtime.DefaultUnstructuredConverter)
// Compare asserts on the equality of objects returned from both stores (object storage and legacy storage)
func Compare(storageObj, legacyObj runtime.Object) bool {
if storageObj == nil || legacyObj == nil {
return storageObj == nil && legacyObj == nil
func Compare(objA, objB runtime.Object) bool {
if objA == nil || objB == nil {
return objA == nil && objB == nil
}
return bytes.Equal(extractSpec(storageObj), extractSpec(legacyObj))
}
func extractSpec(obj runtime.Object) []byte {
cpy := obj.DeepCopyObject()
unstObj, err := defaultConverter.ToUnstructured(cpy)
if objA == objB {
return true
}
mA, err := utils.MetaAccessor(objA)
if err != nil {
return nil
return false
}
// we just want to compare the spec field
jsonObj, err := json.Marshal(unstObj["spec"])
mB, err := utils.MetaAccessor(objB)
if err != nil {
return nil
return false
}
return jsonObj
sA, err := mA.GetSpec()
if err != nil {
return false
}
sB, err := mB.GetSpec()
if err != nil {
return false
}
return apiequality.Semantic.DeepEqual(sA, sB)
}