working commit

This commit is contained in:
2026-03-13 19:02:42 +02:00
parent bebbf79c7a
commit 5c1da77f4c
1329 changed files with 314708 additions and 39 deletions
+38 -5
View File
@@ -12,10 +12,18 @@ package fileoper
import (
"bytes"
"context"
"encoding/json"
"io"
"net/http"
"path"
"strconv"
"mstore/pkg/auxtool"
"mstore/pkg/terms"
yaml "go.yaml.in/yaml/v4"
chart "helm.sh/helm/v4/pkg/chart/v2"
repo "helm.sh/helm/v4/pkg/repo/v1"
)
// GetFile
@@ -79,12 +87,37 @@ func (oper *Operator) GetFile(ctx context.Context, operatorID string, params *Ge
code := http.StatusOK
return code, res, err
}
// TODO: actual chart index
reader := io.NopCloser(bytes.NewReader(nil))
fileDescrs, err := oper.mdb.ListFilesByCollection(ctx, collection)
index := repo.NewIndexFile()
for _, descr := range fileDescrs {
if descr.Type == hcMediaType {
meta := &chart.Metadata{}
oper.logg.Debugf("=== %s", descr.HelmMeta)
err = json.Unmarshal([]byte(descr.HelmMeta), meta)
if err != nil {
code := http.StatusInternalServerError
return code, res, err
}
index.MustAdd(meta, descr.Name, "aaa", descr.HelmHash)
}
}
indexdata, err := yaml.Marshal(index)
if err != nil {
code := http.StatusInternalServerError
return code, res, err
}
reader := io.NopCloser(bytes.NewReader(indexdata))
now := auxtool.TimeNow()
size := int64(len(indexdata))
res = &GetFileResult{
ContentSize: strconv.FormatInt(0, 10),
ContentType: hcMimeType,
Source: reader,
ContentSize: strconv.FormatInt(size, 10),
ContentType: "application/yaml",
Source: reader,
ContentCreatedAt: now,
ContentCreatedBy: terms.ServerID,
ContentUpdatedAt: now,
ContentUpdatedBy: terms.ServerID,
}
code := http.StatusOK
return code, res, err