filecli, filecmd: added uploading as helm chart

This commit is contained in:
2026-03-12 17:17:51 +02:00
parent 95ed9ddb97
commit 27c912d266
6 changed files with 170 additions and 20 deletions
+3
View File
@@ -47,6 +47,8 @@ func (util *FileUtil) MakeFileCmds() *cobra.Command {
Short: "Put file to storage",
Run: util.PutFile,
}
putFileCmd.Flags().BoolVarP(&util.putFileParams.Chart, "chart", "C", false, "Upload as helm chart archive")
subCmd.AddCommand(putFileCmd)
// GetFile
@@ -97,6 +99,7 @@ func (util *FileUtil) MakeFileCmds() *cobra.Command {
Short: "Send file tree to storage as is",
Run: util.ImportFiles,
}
importFilesCmd.Flags().BoolVarP(&util.importFilesParams.Chart, "chart", "C", false, "Upload as helm chart archives")
subCmd.AddCommand(importFilesCmd)
// ExportFiles
+6 -3
View File
@@ -29,6 +29,7 @@ type ImportFilesParams struct {
Source string
Dest string
Progress bool
Chart bool
}
type ImportFilesResult struct {
Files []string `json:"files,omitempty"`
@@ -69,8 +70,6 @@ func (util *FileUtil) importFiles(common *CommonFileParams, params *ImportFilesP
return nil
}
ref.JoinResource(relpath)
//fmt.Printf("====%s %s\n", relpath, ref.Raw())
//return nil
file, err := os.OpenFile(walkpath, os.O_RDONLY, 0)
if err != nil {
putErrors = append(putErrors, err)
@@ -89,7 +88,11 @@ func (util *FileUtil) importFiles(common *CommonFileParams, params *ImportFilesP
mw := filecli.NewBasicAuthMiddleware(ref.Userinfo())
cli := filecli.NewClient(nil, mw)
err = cli.PutFile(ctx, ref.Raw(), file, stat.Size())
mime := defMediaType
if params.Chart {
mime = hcMediaType
}
err = cli.PutFile(ctx, ref.Raw(), mime, file, stat.Size())
if err != nil {
putErrors = append(putErrors, err)
fmt.Printf("- %s: error: %v \n", ref.Raw(), err)
+12 -1
View File
@@ -19,10 +19,16 @@ import (
"mstore/pkg/filecli"
)
const (
defMediaType = "application/octet-stream"
hcMediaType = "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
)
// PutFile
type PutFileParams struct {
Source string
Dest string
Chart bool
}
type PutFileResult struct{}
@@ -56,7 +62,12 @@ func (util *FileUtil) putFile(common *CommonFileParams, params *PutFileParams) (
mw := filecli.NewBasicAuthMiddleware(ref.Userinfo())
cli := filecli.NewClient(nil, mw)
err = cli.PutFile(ctx, ref.Raw(), file, stat.Size())
mime := defMediaType
if params.Chart {
mime = hcMediaType
}
err = cli.PutFile(ctx, ref.Raw(), mime, file, stat.Size())
if err != nil {
return res, err
}