working commit

This commit is contained in:
2026-02-20 13:05:57 +02:00
parent 903a03cf89
commit dcb22b58d9
4 changed files with 37 additions and 5 deletions
+10 -2
View File
@@ -16,6 +16,7 @@ import (
"time"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"mstore/pkg/client"
"mstore/pkg/descr"
@@ -51,12 +52,19 @@ func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
}
const defaultTimeout uint64 = 10
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Username, "user", "u", "", "Username")
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Password, "pass", "p", "", "Password")
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Username, "user", "u", util.commonAccountParams.Username, "Username")
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Password, "pass", "p", util.commonAccountParams.Password, "Password")
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Hostname, "host", "x", defaultHostname, "Hostname")
subCmd.PersistentFlags().Uint64VarP(&util.commonAccountParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
subCmd.MarkFlagsRequiredTogether("user", "pass")
vi := viper.New()
vi.SetEnvPrefix("mstore")
vi.BindEnv("user")
vi.BindEnv("pass")
util.commonAccountParams.Username = vi.GetString("user")
util.commonAccountParams.Password = vi.GetString("pass")
// CreateAccount
var createAccountCmd = &cobra.Command{
Use: "create [user:pass@]hostname[:port] username password",
+9 -1
View File
@@ -23,6 +23,7 @@ import (
"time"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"mstore/pkg/client"
"mstore/pkg/descr"
@@ -43,6 +44,13 @@ func (util *FileUtil) CreateFileCmds() *cobra.Command {
subCmd.MarkPersistentFlagRequired("host")
subCmd.MarkFlagsRequiredTogether("user", "pass")
vi := viper.New()
vi.SetEnvPrefix("mstore")
vi.BindEnv("user")
vi.BindEnv("pass")
util.commonFileParams.Username = vi.GetString("user")
util.commonFileParams.Password = vi.GetString("pass")
// PutFile
var putFileCmd = &cobra.Command{
Use: "put filepath [user:pass@]hostname[:port]/collection/name",
@@ -408,7 +416,7 @@ func (util *FileUtil) importFiles(common *CommonFileParams, params *ImportFilesP
err = client.NewClient().PutFile(ctx, walkPath, dest)
if err != nil {
putErrors = append(putErrors, err)
fmt.Printf("- %s: error\n", walkPath)
fmt.Printf("- %s: error: %v \n", walkPath, err)
} else {
res.Files = append(res.Files, walkPath)
fmt.Printf("- %s: ok\n", walkPath)
+8
View File
@@ -16,6 +16,7 @@ import (
"time"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"mstore/pkg/client"
"mstore/pkg/descr"
@@ -33,6 +34,13 @@ func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
subCmd.PersistentFlags().StringVarP(&util.commonGrantParams.Password, "pass", "p", "", "Password")
subCmd.PersistentFlags().Uint64VarP(&util.commonGrantParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
vi := viper.New()
vi.SetEnvPrefix("mstore")
vi.BindEnv("user")
vi.BindEnv("pass")
util.commonGrantParams.Username = vi.GetString("user")
util.commonGrantParams.Password = vi.GetString("pass")
// CreateGrant
var createGrantCmd = &cobra.Command{
Use: "create [user:pass@]hostname[:port] username|accountId rigth pattern",
+10 -2
View File
@@ -17,9 +17,10 @@ import (
"strings"
"time"
"mstore/pkg/client"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"mstore/pkg/client"
)
func packUserinfo(resurseuri, username, password string) (string, error) {
@@ -53,6 +54,13 @@ func (util *ImageUtil) CreateImageCmds() *cobra.Command {
subCmd.PersistentFlags().Uint64VarP(&util.commonImageParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
subCmd.MarkFlagsRequiredTogether("user", "pass")
vi := viper.New()
vi.SetEnvPrefix("mstore")
vi.BindEnv("user")
vi.BindEnv("pass")
util.commonImageParams.Username = vi.GetString("user")
util.commonImageParams.Password = vi.GetString("pass")
// PushImage
var pushImageCmd = &cobra.Command{
Use: "push filename [user:pass@]hostname[:port]/path:tag",