K8s: use deprecatedInternalID label rather than SQL annotation (#99263)
This commit is contained in:
@@ -3,7 +3,6 @@ package playlist
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -96,12 +95,7 @@ func convertToK8sResource(v *playlistsvc.PlaylistDTO, namespacer request.Namespa
|
||||
if err == nil {
|
||||
meta.SetUpdatedTimestampMillis(v.UpdatedAt)
|
||||
if v.Id > 0 {
|
||||
createdAt := time.UnixMilli(v.CreatedAt)
|
||||
meta.SetRepositoryInfo(&utils.ResourceRepositoryInfo{
|
||||
Name: "SQL",
|
||||
Path: fmt.Sprintf("%d", v.Id),
|
||||
Timestamp: &createdAt,
|
||||
})
|
||||
meta.SetDeprecatedInternalID(v.Id) // nolint:staticcheck
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,12 +129,5 @@ func getLegacyID(item *unstructured.Unstructured) int64 {
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
info, _ := meta.GetRepositoryInfo()
|
||||
if info != nil && info.Name == "SQL" {
|
||||
i, err := strconv.ParseInt(info.Path, 10, 64)
|
||||
if err == nil {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return 0
|
||||
return meta.GetDeprecatedInternalID() // nolint:staticcheck
|
||||
}
|
||||
|
||||
@@ -36,36 +36,36 @@ func TestPlaylistConversion(t *testing.T) {
|
||||
// fmt.Printf("%s", string(out))
|
||||
require.JSONEq(t, `{
|
||||
"metadata": {
|
||||
"name": "abc",
|
||||
"namespace": "org-3",
|
||||
"uid": "f0zxjm7ApxOafsn6DLQZ4Ezp78WRUsZqSc4taOSHq1gX",
|
||||
"resourceVersion": "54321",
|
||||
"creationTimestamp": "1970-01-01T00:00:12Z",
|
||||
"annotations": {
|
||||
"grafana.app/repoPath": "123",
|
||||
"grafana.app/repoName": "SQL",
|
||||
"grafana.app/repoTimestamp":"1970-01-01T00:00:12Z",
|
||||
"grafana.app/updatedTimestamp": "1970-01-01T00:00:54Z"
|
||||
}
|
||||
"name": "abc",
|
||||
"namespace": "org-3",
|
||||
"uid": "f0zxjm7ApxOafsn6DLQZ4Ezp78WRUsZqSc4taOSHq1gX",
|
||||
"resourceVersion": "54321",
|
||||
"creationTimestamp": "1970-01-01T00:00:12Z",
|
||||
"labels": {
|
||||
"grafana.app/deprecatedInternalID": "123"
|
||||
},
|
||||
"annotations": {
|
||||
"grafana.app/updatedTimestamp": "1970-01-01T00:00:54Z"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"title": "MyPlaylists",
|
||||
"interval": "10s",
|
||||
"items": [
|
||||
{
|
||||
"type": "dashboard_by_uid",
|
||||
"value": "UID0"
|
||||
},
|
||||
{
|
||||
"type": "dashboard_by_tag",
|
||||
"value": "tagA"
|
||||
},
|
||||
{
|
||||
"type": "dashboard_by_id",
|
||||
"value": "123"
|
||||
}
|
||||
]
|
||||
"title": "MyPlaylists",
|
||||
"interval": "10s",
|
||||
"items": [
|
||||
{
|
||||
"type": "dashboard_by_uid",
|
||||
"value": "UID0"
|
||||
},
|
||||
{
|
||||
"type": "dashboard_by_tag",
|
||||
"value": "tagA"
|
||||
},
|
||||
{
|
||||
"type": "dashboard_by_id",
|
||||
"value": "123"
|
||||
}
|
||||
]
|
||||
},
|
||||
"status": {}
|
||||
}`, string(out))
|
||||
}`, string(out))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user