fixed charta indexing

This commit is contained in:
2026-03-31 14:40:25 +02:00
parent ec51bf6e34
commit 587ea5ba29
38 changed files with 626 additions and 358 deletions
+7 -3
View File
@@ -15,7 +15,8 @@ import (
"mstore/pkg/auxtool"
"mstore/pkg/terms"
yaml "go.yaml.in/yaml/v4"
yaml "sigs.k8s.io/yaml"
//yaml "go.yaml.in/yaml/v4"
chart "helm.sh/helm/v4/pkg/chart/v2"
repo "helm.sh/helm/v4/pkg/repo/v1"
)
@@ -52,7 +53,8 @@ func (oper *Operator) GetFile(ctx context.Context, operatorID string, params *Ge
oper.iLock.WaitAndLock(resName)
defer oper.iLock.Done(resName)
if filename != "index.yaml" {
const helmIndexName = "index.yaml"
if filename != helmIndexName {
descrExists, fileDescr, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
if err != nil {
code := http.StatusInternalServerError
@@ -81,8 +83,10 @@ func (oper *Operator) GetFile(ctx context.Context, operatorID string, params *Ge
code := http.StatusOK
return code, res, err
}
fileDescrs, err := oper.mdb.ListFilesByCollection(ctx, collection)
index := repo.NewIndexFile()
url := "https://" + path.Join(oper.hostname, collection)
for _, descr := range fileDescrs {
if descr.Type == hcMediaType {
meta := &chart.Metadata{}
@@ -91,7 +95,7 @@ func (oper *Operator) GetFile(ctx context.Context, operatorID string, params *Ge
code := http.StatusInternalServerError
return code, res, err
}
index.MustAdd(meta, descr.Name, "aaa", descr.HelmHash)
index.MustAdd(meta, descr.Name, url, descr.HelmHash)
}
}
+11 -8
View File
@@ -11,22 +11,25 @@ import (
)
type OperatorParams struct {
MainDB *maindb.Database
Store *storage.Storage
MainDB *maindb.Database
Store *storage.Storage
Hostname string
}
type Operator struct {
mdb *maindb.Database
store *storage.Storage
logg *logger.Logger
iLock *locker.Locker
mdb *maindb.Database
store *storage.Storage
logg *logger.Logger
iLock *locker.Locker
hostname string
}
func NewOperator(params *OperatorParams) (*Operator, error) {
var err error
oper := &Operator{
mdb: params.MainDB,
store: params.Store,
mdb: params.MainDB,
store: params.Store,
hostname: params.Hostname,
}
oper.iLock = locker.NewLocker()
oper.logg = logger.NewLoggerWithSubject("fileoper")
+4 -3
View File
@@ -325,14 +325,15 @@ func (srv *Server) Build() error {
// Creating file operator
srv.logg.Infof("Creating file operator")
fileoperParams := &fileoper.OperatorParams{
MainDB: srv.mdb,
Store: srv.stor,
MainDB: srv.mdb,
Store: srv.stor,
Hostname: srv.conf.Hostname,
}
srv.fiop, err = fileoper.NewOperator(fileoperParams)
if err != nil {
return err
}
// Creating operator
// Creating image operator
srv.logg.Infof("Creating operator")
imageoperParams := &imageoper.OperatorParams{
MainDB: srv.mdb,