working commit
This commit is contained in:
@@ -54,7 +54,7 @@ func (db *Database) ListAccounts(ctx context.Context) ([]descr.Account, error) {
|
|||||||
func (db *Database) GetAccountByID(ctx context.Context, accountID string) (bool, *descr.Account, error) {
|
func (db *Database) GetAccountByID(ctx context.Context, accountID string) (bool, *descr.Account, error) {
|
||||||
var err error
|
var err error
|
||||||
var res *descr.Account
|
var res *descr.Account
|
||||||
var exists bool
|
var exists bool = false
|
||||||
|
|
||||||
request := `SELECT * FROM accounts WHERE id = $1 LiMIT 1`
|
request := `SELECT * FROM accounts WHERE id = $1 LiMIT 1`
|
||||||
dbRes := make([]descr.Account, 0)
|
dbRes := make([]descr.Account, 0)
|
||||||
|
|||||||
+35
-2
@@ -72,6 +72,11 @@ func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams)
|
|||||||
var err error
|
var err error
|
||||||
res := &GetAccountResult{}
|
res := &GetAccountResult{}
|
||||||
|
|
||||||
|
if params.Username == "" && params.AccountID == "" {
|
||||||
|
err := fmt.Errorf("Empty username and accountId parameter")
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
var accountDescr *descr.Account
|
var accountDescr *descr.Account
|
||||||
var accountExists bool
|
var accountExists bool
|
||||||
switch {
|
switch {
|
||||||
@@ -93,6 +98,13 @@ func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams)
|
|||||||
err := fmt.Errorf("Account with name %s dont exists", params.Username)
|
err := fmt.Errorf("Account with name %s dont exists", params.Username)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
err := fmt.Errorf("Empty username and accountId parameter")
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
if accountDescr == nil {
|
||||||
|
err := fmt.Errorf("Null account desriptor")
|
||||||
|
return res, err
|
||||||
}
|
}
|
||||||
accountShort := &descr.AccountShort{
|
accountShort := &descr.AccountShort{
|
||||||
ID: accountDescr.ID,
|
ID: accountDescr.ID,
|
||||||
@@ -136,7 +148,10 @@ type UpdateAccountResult struct{}
|
|||||||
func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountParams) (*UpdateAccountResult, error) {
|
func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountParams) (*UpdateAccountResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &UpdateAccountResult{}
|
res := &UpdateAccountResult{}
|
||||||
|
if params.Username == "" && params.AccountID == "" {
|
||||||
|
err := fmt.Errorf("Empty username and accountId parameter")
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
var accountDescr *descr.Account
|
var accountDescr *descr.Account
|
||||||
var accountExists bool
|
var accountExists bool
|
||||||
switch {
|
switch {
|
||||||
@@ -158,6 +173,13 @@ func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountPa
|
|||||||
err := fmt.Errorf("Account with name %s dont exists", params.Username)
|
err := fmt.Errorf("Account with name %s dont exists", params.Username)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
err := fmt.Errorf("Empty username and accountId parameter")
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
if accountDescr == nil {
|
||||||
|
err := fmt.Errorf("Null account desriptor")
|
||||||
|
return res, err
|
||||||
}
|
}
|
||||||
now := auxtool.TimeNow()
|
now := auxtool.TimeNow()
|
||||||
if params.NewUsername != "" {
|
if params.NewUsername != "" {
|
||||||
@@ -191,6 +213,11 @@ func (oper *Operator) DeleteAccount(ctx context.Context, params *DeleteAccountPa
|
|||||||
var err error
|
var err error
|
||||||
res := &DeleteAccountResult{}
|
res := &DeleteAccountResult{}
|
||||||
|
|
||||||
|
if params.Username == "" && params.AccountID == "" {
|
||||||
|
err := fmt.Errorf("Empty username and accountId parameter")
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
var accountDescr *descr.Account
|
var accountDescr *descr.Account
|
||||||
var accountExists bool
|
var accountExists bool
|
||||||
switch {
|
switch {
|
||||||
@@ -212,8 +239,14 @@ func (oper *Operator) DeleteAccount(ctx context.Context, params *DeleteAccountPa
|
|||||||
err := fmt.Errorf("Account with name %s dont exists", params.Username)
|
err := fmt.Errorf("Account with name %s dont exists", params.Username)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
err := fmt.Errorf("Empty username and accountId parameter")
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
if accountDescr == nil {
|
||||||
|
err := fmt.Errorf("Null account desriptor")
|
||||||
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = oper.mdb.DeleteAllGrantsForAccountID(ctx, accountDescr.ID)
|
err = oper.mdb.DeleteAllGrantsForAccountID(ctx, accountDescr.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
|
|||||||
createAccountCmd.Flags().StringVarP(&util.createAccountParams.NewPassword, "newpass", "P", "", "New account password")
|
createAccountCmd.Flags().StringVarP(&util.createAccountParams.NewPassword, "newpass", "P", "", "New account password")
|
||||||
createAccountCmd.MarkFlagRequired("host")
|
createAccountCmd.MarkFlagRequired("host")
|
||||||
createAccountCmd.MarkFlagsRequiredTogether("newuser", "newpass")
|
createAccountCmd.MarkFlagsRequiredTogether("newuser", "newpass")
|
||||||
|
createAccountCmd.MarkFlagsRequiredTogether("username", "password")
|
||||||
|
|
||||||
subCmd.AddCommand(createAccountCmd)
|
subCmd.AddCommand(createAccountCmd)
|
||||||
|
|
||||||
@@ -60,8 +61,12 @@ func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
|
|||||||
getAccountCmd.Flags().StringVarP(&util.getAccountParams.Username, "username", "u", "", "Username")
|
getAccountCmd.Flags().StringVarP(&util.getAccountParams.Username, "username", "u", "", "Username")
|
||||||
getAccountCmd.Flags().StringVarP(&util.getAccountParams.Password, "password", "p", "", "Password")
|
getAccountCmd.Flags().StringVarP(&util.getAccountParams.Password, "password", "p", "", "Password")
|
||||||
getAccountCmd.Flags().Uint64VarP(&util.getAccountParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
getAccountCmd.Flags().Uint64VarP(&util.getAccountParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
getAccountCmd.Flags().StringVarP(&util.getAccountParams.AccountID, "id", "I", "", "Account ID")
|
getAccountCmd.Flags().StringVarP(&util.getAccountParams.AccountID, "id", "I", "", "Account ID or name")
|
||||||
|
getAccountCmd.Flags().StringVarP(&util.getAccountParams.AccountID, "name", "n", "", "Account ID or name")
|
||||||
|
|
||||||
getAccountCmd.MarkFlagRequired("host")
|
getAccountCmd.MarkFlagRequired("host")
|
||||||
|
getAccountCmd.MarkFlagsOneRequired("id", "name")
|
||||||
|
getAccountCmd.MarkFlagsRequiredTogether("username", "password")
|
||||||
|
|
||||||
subCmd.AddCommand(getAccountCmd)
|
subCmd.AddCommand(getAccountCmd)
|
||||||
|
|
||||||
@@ -75,11 +80,13 @@ func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
|
|||||||
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.Password, "password", "p", "", "Password")
|
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.Password, "password", "p", "", "Password")
|
||||||
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.Hostname, "host", "x", "", "File path")
|
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.Hostname, "host", "x", "", "File path")
|
||||||
updateAccountCmd.Flags().Uint64VarP(&util.updateAccountParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
updateAccountCmd.Flags().Uint64VarP(&util.updateAccountParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
updateAccountCmd.MarkFlagRequired("host")
|
|
||||||
|
|
||||||
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.AccountID, "id", "I", "", "Account ID")
|
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.AccountID, "id", "I", "", "Account ID or username")
|
||||||
|
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.AccountID, "name", "n", "", "Account ID or username")
|
||||||
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.NewUsername, "newuser", "U", "", "New username")
|
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.NewUsername, "newuser", "U", "", "New username")
|
||||||
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.NewPassword, "pass", "P", "", "New password")
|
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.NewPassword, "pass", "P", "", "New password")
|
||||||
|
updateAccountCmd.MarkFlagRequired("host")
|
||||||
|
updateAccountCmd.MarkFlagsOneRequired("id", "name")
|
||||||
|
|
||||||
subCmd.AddCommand(updateAccountCmd)
|
subCmd.AddCommand(updateAccountCmd)
|
||||||
|
|
||||||
@@ -93,9 +100,12 @@ func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
|
|||||||
deleteAccountCmd.Flags().StringVarP(&util.deleteAccountParams.Password, "password", "p", "", "Password")
|
deleteAccountCmd.Flags().StringVarP(&util.deleteAccountParams.Password, "password", "p", "", "Password")
|
||||||
deleteAccountCmd.Flags().StringVarP(&util.deleteAccountParams.Hostname, "host", "x", defaultHostname, "Hostname")
|
deleteAccountCmd.Flags().StringVarP(&util.deleteAccountParams.Hostname, "host", "x", defaultHostname, "Hostname")
|
||||||
deleteAccountCmd.Flags().Uint64VarP(&util.deleteAccountParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
deleteAccountCmd.Flags().Uint64VarP(&util.deleteAccountParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
deleteAccountCmd.MarkFlagRequired("host")
|
|
||||||
|
|
||||||
deleteAccountCmd.Flags().StringVarP(&util.deleteAccountParams.AccountID, "id", "I", "", "Account ID")
|
deleteAccountCmd.Flags().StringVarP(&util.deleteAccountParams.AccountID, "id", "I", "", "Account ID")
|
||||||
|
deleteAccountCmd.Flags().StringVarP(&util.updateAccountParams.AccountID, "name", "n", "", "Account ID or username")
|
||||||
|
deleteAccountCmd.MarkFlagRequired("host")
|
||||||
|
deleteAccountCmd.MarkFlagsOneRequired("id", "name")
|
||||||
|
deleteAccountCmd.MarkFlagsRequiredTogether("username", "password")
|
||||||
|
|
||||||
subCmd.AddCommand(deleteAccountCmd)
|
subCmd.AddCommand(deleteAccountCmd)
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,14 @@ func (util *FileUtil) CreateFileCmds() *cobra.Command {
|
|||||||
Short: "Put file to storage",
|
Short: "Put file to storage",
|
||||||
Run: util.PutFile,
|
Run: util.PutFile,
|
||||||
}
|
}
|
||||||
putFileCmd.Flags().StringVarP(&util.putFileParams.Username, "username", "u", "", "Username")
|
putFileCmd.Flags().StringVarP(&util.putFileParams.Username, "user", "u", "", "Username")
|
||||||
putFileCmd.Flags().StringVarP(&util.putFileParams.Password, "password", "p", "", "Password")
|
putFileCmd.Flags().StringVarP(&util.putFileParams.Password, "pass", "p", "", "Password")
|
||||||
putFileCmd.Flags().StringVarP(&util.putFileParams.Source, "src", "s", "", "Source path")
|
putFileCmd.Flags().StringVarP(&util.putFileParams.Source, "src", "s", "", "Source path")
|
||||||
putFileCmd.Flags().StringVarP(&util.putFileParams.Dest, "dest", "d", "", "Desctination path")
|
putFileCmd.Flags().StringVarP(&util.putFileParams.Dest, "dest", "d", "", "Desctination path")
|
||||||
putFileCmd.Flags().Uint64VarP(&util.putFileParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
putFileCmd.Flags().Uint64VarP(&util.putFileParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
|
putFileCmd.MarkFlagsRequiredTogether("src", "dest")
|
||||||
|
putFileCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
putFileCmd.MarkFlagFilename("src")
|
||||||
|
|
||||||
subCmd.AddCommand(putFileCmd)
|
subCmd.AddCommand(putFileCmd)
|
||||||
|
|
||||||
@@ -46,11 +49,13 @@ func (util *FileUtil) CreateFileCmds() *cobra.Command {
|
|||||||
Short: "Get file from storage",
|
Short: "Get file from storage",
|
||||||
Run: util.GetFile,
|
Run: util.GetFile,
|
||||||
}
|
}
|
||||||
getFileCmd.Flags().StringVarP(&util.getFileParams.Username, "username", "u", "", "Username")
|
getFileCmd.Flags().StringVarP(&util.getFileParams.Username, "user", "u", "", "Username")
|
||||||
getFileCmd.Flags().StringVarP(&util.getFileParams.Password, "password", "p", "", "Password")
|
getFileCmd.Flags().StringVarP(&util.getFileParams.Password, "pass", "p", "", "Password")
|
||||||
getFileCmd.Flags().StringVarP(&util.getFileParams.Source, "src", "s", "", "Source path")
|
getFileCmd.Flags().StringVarP(&util.getFileParams.Source, "src", "s", "", "Source path")
|
||||||
getFileCmd.Flags().StringVarP(&util.getFileParams.Dest, "dest", "d", "", "Desctination path")
|
getFileCmd.Flags().StringVarP(&util.getFileParams.Dest, "dest", "d", "", "Desctination path")
|
||||||
getFileCmd.Flags().Uint64VarP(&util.getFileParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
getFileCmd.Flags().Uint64VarP(&util.getFileParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
|
getFileCmd.MarkFlagsRequiredTogether("src", "dest")
|
||||||
|
getFileCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
subCmd.AddCommand(getFileCmd)
|
subCmd.AddCommand(getFileCmd)
|
||||||
|
|
||||||
@@ -60,10 +65,12 @@ func (util *FileUtil) CreateFileCmds() *cobra.Command {
|
|||||||
Short: "Show file information",
|
Short: "Show file information",
|
||||||
Run: util.FileInfo,
|
Run: util.FileInfo,
|
||||||
}
|
}
|
||||||
fileInfoCmd.Flags().StringVarP(&util.fileInfoParams.Username, "username", "u", "", "Username")
|
fileInfoCmd.Flags().StringVarP(&util.fileInfoParams.Username, "user", "u", "", "Username")
|
||||||
fileInfoCmd.Flags().StringVarP(&util.fileInfoParams.Password, "password", "p", "", "Password")
|
fileInfoCmd.Flags().StringVarP(&util.fileInfoParams.Password, "pass", "p", "", "Password")
|
||||||
fileInfoCmd.Flags().StringVarP(&util.fileInfoParams.Filepath, "path", "d", "", "File path")
|
fileInfoCmd.Flags().StringVarP(&util.fileInfoParams.Filepath, "path", "d", "", "File path")
|
||||||
fileInfoCmd.Flags().Uint64VarP(&util.fileInfoParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
fileInfoCmd.Flags().Uint64VarP(&util.fileInfoParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
|
fileInfoCmd.MarkFlagRequired("path")
|
||||||
|
fileInfoCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
subCmd.AddCommand(fileInfoCmd)
|
subCmd.AddCommand(fileInfoCmd)
|
||||||
|
|
||||||
@@ -73,10 +80,12 @@ func (util *FileUtil) CreateFileCmds() *cobra.Command {
|
|||||||
Short: "Delete file in storage",
|
Short: "Delete file in storage",
|
||||||
Run: util.DeleteFile,
|
Run: util.DeleteFile,
|
||||||
}
|
}
|
||||||
deleteFileCmd.Flags().StringVarP(&util.deleteFileParams.Username, "username", "u", "", "Username")
|
deleteFileCmd.Flags().StringVarP(&util.deleteFileParams.Username, "user", "u", "", "Username")
|
||||||
deleteFileCmd.Flags().StringVarP(&util.deleteFileParams.Password, "password", "p", "", "Password")
|
deleteFileCmd.Flags().StringVarP(&util.deleteFileParams.Password, "pass", "p", "", "Password")
|
||||||
deleteFileCmd.Flags().StringVarP(&util.deleteFileParams.Filepath, "path", "d", "", "File path")
|
deleteFileCmd.Flags().StringVarP(&util.deleteFileParams.Filepath, "path", "d", "", "File path")
|
||||||
deleteFileCmd.Flags().Uint64VarP(&util.deleteFileParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
deleteFileCmd.Flags().Uint64VarP(&util.deleteFileParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
|
deleteFileCmd.MarkFlagRequired("path")
|
||||||
|
deleteFileCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
subCmd.AddCommand(deleteFileCmd)
|
subCmd.AddCommand(deleteFileCmd)
|
||||||
|
|
||||||
@@ -101,6 +110,7 @@ func (util *FileUtil) CreateFilesCmds() *cobra.Command {
|
|||||||
listFilesCmd.Flags().StringVarP(&util.listFilesParams.Filepath, "catalog", "c", "", "Catalog path")
|
listFilesCmd.Flags().StringVarP(&util.listFilesParams.Filepath, "catalog", "c", "", "Catalog path")
|
||||||
listFilesCmd.Flags().Uint64VarP(&util.listFilesParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
listFilesCmd.Flags().Uint64VarP(&util.listFilesParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
listFilesCmd.MarkFlagRequired("catalog")
|
listFilesCmd.MarkFlagRequired("catalog")
|
||||||
|
listFilesCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
subCmd.AddCommand(listFilesCmd)
|
subCmd.AddCommand(listFilesCmd)
|
||||||
|
|
||||||
|
|||||||
@@ -53,11 +53,12 @@ func (util *ImageUtil) CreateImageCmds() *cobra.Command {
|
|||||||
Short: "Show container image info",
|
Short: "Show container image info",
|
||||||
Run: util.ImageInfo,
|
Run: util.ImageInfo,
|
||||||
}
|
}
|
||||||
imageInfoCmd.Flags().StringVarP(&util.imageInfoParams.Username, "username", "u", "", "Username")
|
imageInfoCmd.Flags().StringVarP(&util.imageInfoParams.Username, "user", "u", "", "Username")
|
||||||
imageInfoCmd.Flags().StringVarP(&util.imageInfoParams.Password, "password", "p", "", "Password")
|
imageInfoCmd.Flags().StringVarP(&util.imageInfoParams.Password, "pass", "p", "", "Password")
|
||||||
imageInfoCmd.Flags().StringVarP(&util.imageInfoParams.Imagepath, "image", "i", "", "Remote image path")
|
imageInfoCmd.Flags().StringVarP(&util.imageInfoParams.Imagepath, "image", "i", "", "Remote image path")
|
||||||
imageInfoCmd.Flags().Uint64VarP(&util.imageInfoParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
imageInfoCmd.Flags().Uint64VarP(&util.imageInfoParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
imageInfoCmd.MarkFlagRequired("image")
|
imageInfoCmd.MarkFlagRequired("image")
|
||||||
|
imageInfoCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
subCmd.AddCommand(imageInfoCmd)
|
subCmd.AddCommand(imageInfoCmd)
|
||||||
|
|
||||||
@@ -67,13 +68,15 @@ func (util *ImageUtil) CreateImageCmds() *cobra.Command {
|
|||||||
Short: "Pull container image into local file",
|
Short: "Pull container image into local file",
|
||||||
Run: util.PullImage,
|
Run: util.PullImage,
|
||||||
}
|
}
|
||||||
pullImageCmd.Flags().StringVarP(&util.pullImageParams.Username, "username", "u", "", "Username")
|
pullImageCmd.Flags().StringVarP(&util.pullImageParams.Username, "user", "u", "", "Username")
|
||||||
pullImageCmd.Flags().StringVarP(&util.pullImageParams.Password, "password", "p", "", "Password")
|
pullImageCmd.Flags().StringVarP(&util.pullImageParams.Password, "pass", "p", "", "Password")
|
||||||
pullImageCmd.Flags().StringVarP(&util.pullImageParams.Imagepath, "image", "i", "", "Remote image path")
|
pullImageCmd.Flags().StringVarP(&util.pullImageParams.Imagepath, "image", "i", "", "Remote image path")
|
||||||
pullImageCmd.Flags().StringVarP(&util.pullImageParams.Filepath, "file", "f", "", "Local file path")
|
pullImageCmd.Flags().StringVarP(&util.pullImageParams.Filepath, "file", "f", "", "Local file path")
|
||||||
pullImageCmd.Flags().Uint64VarP(&util.pullImageParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
pullImageCmd.Flags().Uint64VarP(&util.pullImageParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
pullImageCmd.MarkFlagRequired("image")
|
pullImageCmd.MarkFlagRequired("image")
|
||||||
pullImageCmd.MarkFlagRequired("file")
|
pullImageCmd.MarkFlagRequired("file")
|
||||||
|
pullImageCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
subCmd.AddCommand(pullImageCmd)
|
subCmd.AddCommand(pullImageCmd)
|
||||||
|
|
||||||
// PushImage
|
// PushImage
|
||||||
@@ -82,13 +85,15 @@ func (util *ImageUtil) CreateImageCmds() *cobra.Command {
|
|||||||
Short: "Pull container image into local file",
|
Short: "Pull container image into local file",
|
||||||
Run: util.PushImage,
|
Run: util.PushImage,
|
||||||
}
|
}
|
||||||
pushImageCmd.Flags().StringVarP(&util.pushImageParams.Username, "username", "u", "", "Username")
|
pushImageCmd.Flags().StringVarP(&util.pushImageParams.Username, "user", "u", "", "Username")
|
||||||
pushImageCmd.Flags().StringVarP(&util.pushImageParams.Password, "password", "p", "", "Password")
|
pushImageCmd.Flags().StringVarP(&util.pushImageParams.Password, "pass", "p", "", "Password")
|
||||||
pushImageCmd.Flags().StringVarP(&util.pushImageParams.Imagepath, "image", "i", "", "Remote image path")
|
pushImageCmd.Flags().StringVarP(&util.pushImageParams.Imagepath, "image", "i", "", "Remote image path")
|
||||||
pushImageCmd.Flags().StringVarP(&util.pushImageParams.Filepath, "file", "f", "", "Local file path")
|
pushImageCmd.Flags().StringVarP(&util.pushImageParams.Filepath, "file", "f", "", "Local file path")
|
||||||
pushImageCmd.Flags().Uint64VarP(&util.pushImageParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
pushImageCmd.Flags().Uint64VarP(&util.pushImageParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
pushImageCmd.MarkFlagRequired("image")
|
pushImageCmd.MarkFlagRequired("image")
|
||||||
pushImageCmd.MarkFlagRequired("file")
|
pushImageCmd.MarkFlagRequired("file")
|
||||||
|
pushImageCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
subCmd.AddCommand(pushImageCmd)
|
subCmd.AddCommand(pushImageCmd)
|
||||||
|
|
||||||
return subCmd
|
return subCmd
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* Distribution of this work is permitted, but commercial use and
|
* Distribution of this work is permitted, but commercial use and
|
||||||
* modifications are strictly prohibited.
|
* modifications are strictly prohibited.
|
||||||
*/
|
*/
|
||||||
package client
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mstore/app/server"
|
"mstore/app/server"
|
||||||
|
"mstore/pkg/client"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
@@ -65,7 +66,7 @@ func TestAccountLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// ServiceHello
|
// ServiceHello
|
||||||
fmt.Printf("=== ServiceHello ===\n")
|
fmt.Printf("=== ServiceHello ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
helloRes, err := cli.ServiceHello(ctx, srvaddr+"/hello", 1*time.Second)
|
helloRes, err := cli.ServiceHello(ctx, srvaddr+"/hello", 1*time.Second)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -79,7 +80,7 @@ func TestAccountLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// CreateAccount
|
// CreateAccount
|
||||||
fmt.Printf("=== CreateAccount ===\n")
|
fmt.Printf("=== CreateAccount ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -89,7 +90,7 @@ func TestAccountLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// GetAccount
|
// GetAccount
|
||||||
fmt.Printf("=== GetAccount ===\n")
|
fmt.Printf("=== GetAccount ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ func TestAccountLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// ListAccounts
|
// ListAccounts
|
||||||
fmt.Printf("=== ListAccounts ===\n")
|
fmt.Printf("=== ListAccounts ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -115,7 +116,7 @@ func TestAccountLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// DeleteAccount
|
// DeleteAccount
|
||||||
fmt.Printf("=== DeleteAccount ===\n")
|
fmt.Printf("=== DeleteAccount ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
* Distribution of this work is permitted, but commercial use and
|
* Distribution of this work is permitted, but commercial use and
|
||||||
* modifications are strictly prohibited.
|
* modifications are strictly prohibited.
|
||||||
*/
|
*/
|
||||||
package client
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mstore/app/server"
|
"mstore/app/server"
|
||||||
|
"mstore/pkg/client"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -67,7 +68,7 @@ func xxxTestFileLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// ServiceHello
|
// ServiceHello
|
||||||
fmt.Printf("=== ServiceHello ===\n")
|
fmt.Printf("=== ServiceHello ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
helloRes, err := cli.ServiceHello(ctx, srvaddr+"/hello", 1*time.Second)
|
helloRes, err := cli.ServiceHello(ctx, srvaddr+"/hello", 1*time.Second)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -88,7 +89,7 @@ func xxxTestFileLife(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
fmt.Printf("=== PutFile ===\n")
|
fmt.Printf("=== PutFile ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -98,7 +99,7 @@ func xxxTestFileLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// FileInfo
|
// FileInfo
|
||||||
fmt.Printf("=== FileInfo ===\n")
|
fmt.Printf("=== FileInfo ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -110,7 +111,7 @@ func xxxTestFileLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// GetFile
|
// GetFile
|
||||||
fmt.Printf("=== GetFile ===\n")
|
fmt.Printf("=== GetFile ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -124,7 +125,7 @@ func xxxTestFileLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// ListFiles
|
// ListFiles
|
||||||
fmt.Printf("=== ListFiles ===\n")
|
fmt.Printf("=== ListFiles ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -136,7 +137,7 @@ func xxxTestFileLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// DeleteFile
|
// DeleteFile
|
||||||
fmt.Printf("=== DeleteFile ===\n")
|
fmt.Printf("=== DeleteFile ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -146,7 +147,7 @@ func xxxTestFileLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// !FileInfo
|
// !FileInfo
|
||||||
fmt.Printf("=== FileInfo ===\n")
|
fmt.Printf("=== FileInfo ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
* Distribution of this work is permitted, but commercial use and
|
* Distribution of this work is permitted, but commercial use and
|
||||||
* modifications are strictly prohibited.
|
* modifications are strictly prohibited.
|
||||||
*/
|
*/
|
||||||
package client
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mstore/app/server"
|
"mstore/app/server"
|
||||||
|
"mstore/pkg/client"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
@@ -67,7 +68,7 @@ func xxxTestImageLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// ServiceHello
|
// ServiceHello
|
||||||
fmt.Printf("=== ServiceHello ===\n")
|
fmt.Printf("=== ServiceHello ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
helloRes, err := cli.ServiceHello(ctx, srvaddr+"/hello", 1*time.Second)
|
helloRes, err := cli.ServiceHello(ctx, srvaddr+"/hello", 1*time.Second)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -76,7 +77,7 @@ func xxxTestImageLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// PishImage
|
// PishImage
|
||||||
fmt.Printf("=== PushImage ===\n")
|
fmt.Printf("=== PushImage ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
|
||||||
err := cli.PushImage(ctx, "test-oci.img", srvaddr+"/foo/test:123")
|
err := cli.PushImage(ctx, "test-oci.img", srvaddr+"/foo/test:123")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -84,7 +85,7 @@ func xxxTestImageLife(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// ImageInfo
|
// ImageInfo
|
||||||
fmt.Printf("=== ImageInfo ===\n")
|
fmt.Printf("=== ImageInfo ===\n")
|
||||||
cli := NewClient()
|
cli := client.NewClient()
|
||||||
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
|
||||||
info, err := cli.ImageInfo(ctx, srvaddr+"/foo/test:123")
|
info, err := cli.ImageInfo(ctx, srvaddr+"/foo/test:123")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
Reference in New Issue
Block a user