2024-01-24 16:09:39 +00:00
|
|
|
package sideload
|
|
|
|
|
|
|
|
import (
|
2024-09-29 15:03:11 +00:00
|
|
|
"git.solsynth.dev/goatworks/roadsign/pkg/navi"
|
|
|
|
"git.solsynth.dev/goatworks/roadsign/pkg/warden"
|
2024-01-24 16:09:39 +00:00
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
"github.com/samber/lo"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getApplications(c *fiber.Ctx) error {
|
|
|
|
applications := lo.FlatMap(navi.R.Regions, func(item *navi.Region, idx int) []warden.Application {
|
|
|
|
return item.Applications
|
|
|
|
})
|
|
|
|
|
|
|
|
return c.JSON(applications)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getApplicationLogs(c *fiber.Ctx) error {
|
|
|
|
if instance, ok := lo.Find(warden.InstancePool, func(item *warden.AppInstance) bool {
|
|
|
|
return item.Manifest.ID == c.Params("id")
|
|
|
|
}); !ok {
|
|
|
|
return fiber.NewError(fiber.StatusNotFound)
|
|
|
|
} else {
|
|
|
|
return c.SendString(instance.Logs())
|
|
|
|
}
|
|
|
|
}
|