K8s: use deprecatedInternalID label rather than SQL annotation (#99263)
This commit is contained in:
@@ -223,6 +223,11 @@ func (c *K8sResourceClient) sanitizeObject(v *unstructured.Unstructured, replace
|
||||
|
||||
replaceMeta = append(replaceMeta, "creationTimestamp", "resourceVersion", "uid")
|
||||
for _, key := range replaceMeta {
|
||||
if key == "labels" {
|
||||
delete(meta, key)
|
||||
continue
|
||||
}
|
||||
|
||||
old, ok := meta[key]
|
||||
if ok {
|
||||
require.NotEmpty(c.t, old)
|
||||
|
||||
@@ -4,13 +4,14 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/tests/apis"
|
||||
"github.com/grafana/grafana/pkg/tests/testinfra"
|
||||
"github.com/grafana/grafana/pkg/tests/testsuite"
|
||||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
var gvrTeams = schema.GroupVersionResource{
|
||||
@@ -51,7 +52,7 @@ func TestIntegrationIdentity(t *testing.T) {
|
||||
})
|
||||
rsp, err := teamClient.Resource.List(ctx, metav1.ListOptions{})
|
||||
require.NoError(t, err)
|
||||
found := teamClient.SanitizeJSONList(rsp, "name")
|
||||
found := teamClient.SanitizeJSONList(rsp, "name", "labels")
|
||||
require.JSONEq(t, `{
|
||||
"items": [
|
||||
{
|
||||
|
||||
@@ -523,17 +523,17 @@ func doPlaylistTests(t *testing.T, helper *apis.K8sTestHelper) *apis.K8sTestHelp
|
||||
k8sList, err := client.Resource.List(context.Background(), metav1.ListOptions{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(k8sList.Items))
|
||||
require.JSONEq(t, expectedResult, client.SanitizeJSON(&k8sList.Items[0]))
|
||||
require.JSONEq(t, expectedResult, client.SanitizeJSON(&k8sList.Items[0], "labels"))
|
||||
|
||||
// Get should return the same result
|
||||
found, err := client.Resource.Get(context.Background(), uid, metav1.GetOptions{})
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, expectedResult, client.SanitizeJSON(found))
|
||||
require.JSONEq(t, expectedResult, client.SanitizeJSON(found, "labels"))
|
||||
|
||||
// Now modify the interval
|
||||
updatedInterval := `"interval": "10m"`
|
||||
legacyPayload = strings.Replace(legacyPayload, `"interval": "20s"`, updatedInterval, 1)
|
||||
require.JSONEq(t, expectedResult, client.SanitizeJSON(&k8sList.Items[0]))
|
||||
require.JSONEq(t, expectedResult, client.SanitizeJSON(&k8sList.Items[0], "labels"))
|
||||
dtoResponse := apis.DoRequest(helper, apis.RequestParams{
|
||||
User: client.Args.User,
|
||||
Method: http.MethodPut,
|
||||
|
||||
Reference in New Issue
Block a user