app: added helm tgz handle
This commit is contained in:
+13
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user