forked from security/hakurei
cmd/pkgserver: add get endpoint
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"hakurei.app/internal/pkg"
|
||||
@@ -25,10 +26,11 @@ type PackageIndex struct {
|
||||
|
||||
type PackageIndexEntry struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Website string `json:"website"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Website string `json:"website,omitempty"`
|
||||
Version string `json:"version"`
|
||||
status []byte
|
||||
Status string `json:"report,omitempty"`
|
||||
status []byte `json:"-"`
|
||||
}
|
||||
|
||||
func createPackageIndex(cache *pkg.Cache, report *rosa.Report) (_ *PackageIndex, err error) {
|
||||
@@ -43,16 +45,20 @@ func createPackageIndex(cache *pkg.Cache, report *rosa.Report) (_ *PackageIndex,
|
||||
id := cache.Ident(a)
|
||||
st, n := report.ArtifactOf(id)
|
||||
var status []byte
|
||||
var statusUrl string
|
||||
if n < 1 {
|
||||
status = nil
|
||||
statusUrl = ""
|
||||
} else {
|
||||
status = st
|
||||
statusUrl = fmt.Sprintf("/api/status/%s.log", m.Name)
|
||||
}
|
||||
entry := PackageIndexEntry{
|
||||
Name: m.Name,
|
||||
Description: m.Description,
|
||||
Website: m.Website,
|
||||
Version: v,
|
||||
Status: statusUrl,
|
||||
status: status,
|
||||
}
|
||||
work[p] = entry
|
||||
|
||||
Reference in New Issue
Block a user