mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
Playlist: Implement the entire API with k8s client (#77596)
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user