app: added helm tgz handle

This commit is contained in:
2026-03-12 16:59:29 +02:00
parent 0d67944966
commit 95ed9ddb97
3182 changed files with 957097 additions and 133 deletions
+13 -1
View File
@@ -31,7 +31,10 @@ type PutFileParams struct {
}
type PutFileResult struct{}
const defaultContentType = "application/octet-stream"
const (
defaultContentType = "application/octet-stream"
hcMimeType = "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
)
// TODO: checking catalog and file names conflict
func (oper *Operator) PutFile(ctx context.Context, operatorID string, params *PutFileParams) (int, *PutFileResult, error) {
@@ -71,6 +74,11 @@ func (oper *Operator) PutFile(ctx context.Context, operatorID string, params *Pu
code := http.StatusInternalServerError
return code, res, err
}
var helmHash string
var helmMeta string
if contentType == hcMimeType {
helmHash, helmMeta, err = oper.store.HelmMeta(tmpname)
}
descrExists, fileDescr, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
if err != nil {
@@ -85,6 +93,8 @@ func (oper *Operator) PutFile(ctx context.Context, operatorID string, params *Pu
fileDescr.UpdatedAt = now
fileDescr.Type = contentType
fileDescr.UpdatedBy = operatorID
fileDescr.HelmMeta = helmMeta
fileDescr.HelmHash = helmHash
err = oper.mdb.UpdateFileByID(ctx, fileDescr.ID, fileDescr)
if err != nil {
code := http.StatusInternalServerError
@@ -102,6 +112,8 @@ func (oper *Operator) PutFile(ctx context.Context, operatorID string, params *Pu
UpdatedAt: now,
CreatedBy: operatorID,
UpdatedBy: operatorID,
HelmMeta: helmMeta,
HelmHash: helmHash,
}
err = oper.mdb.InsertFile(ctx, fileDescr)
if err != nil {