working commit
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strconv"
|
||||
|
||||
"mstore/pkg/auxoci"
|
||||
@@ -470,3 +471,33 @@ func (oper *Operator) GetReferer(ctx context.Context, params *GetRefererParams)
|
||||
res.Reference = manifests[0].Reference
|
||||
return res, http.StatusOK, err
|
||||
}
|
||||
|
||||
type ListManifestsParams struct {
|
||||
N int64
|
||||
}
|
||||
type ListManifestsResult struct {
|
||||
Catalog []string `json:"repositories"`
|
||||
}
|
||||
|
||||
func (oper *Operator) ListManifests(ctx context.Context, params *ListManifestsParams) (*ListManifestsResult, int, error) {
|
||||
var err error
|
||||
res := &ListManifestsResult{
|
||||
Catalog: make([]string, 0),
|
||||
}
|
||||
refMap := make(map[string]bool)
|
||||
descrs, err := oper.mdb.ListAllManifests(ctx)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
for _, descr := range descrs {
|
||||
_, yet := refMap[descr.Reference]
|
||||
if !yet {
|
||||
refMap[descr.Reference] = true
|
||||
}
|
||||
}
|
||||
for key, _ := range refMap {
|
||||
res.Catalog = append(res.Catalog, key)
|
||||
}
|
||||
slices.Sort(res.Catalog)
|
||||
return res, http.StatusOK, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user