Playlist: Implement the entire API with k8s client (#77596)

This commit is contained in:
Ryan McKinley
2023-11-03 09:25:29 -07:00
committed by GitHub
parent 224279fe0e
commit 549787d4f9
4 changed files with 254 additions and 140 deletions
+21
View File
@@ -16,6 +16,27 @@ import (
playlistsvc "github.com/grafana/grafana/pkg/services/playlist"
)
func LegacyUpdateCommandToUnstructured(cmd playlistsvc.UpdatePlaylistCommand) unstructured.Unstructured {
items := []map[string]string{}
for _, item := range cmd.Items {
items = append(items, map[string]string{
"type": item.Type,
"value": item.Value,
})
}
obj := unstructured.Unstructured{
Object: map[string]interface{}{
"spec": map[string]interface{}{
"title": cmd.Name,
"interval": cmd.Interval,
"items": items,
},
},
}
obj.SetName(cmd.UID)
return obj
}
func UnstructuredToLegacyPlaylist(item unstructured.Unstructured) *playlistsvc.Playlist {
spec := item.Object["spec"].(map[string]any)
return &playlistsvc.Playlist{