working commit
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign no-dependencies no-installinfo
|
||||
|
||||
SUBDIRS = mans
|
||||
|
||||
@@ -13,6 +13,10 @@ const (
|
||||
defaultHostname = "localhost:1025"
|
||||
)
|
||||
|
||||
func NewAccountUtil() *AccountUtil {
|
||||
return &AccountUtil{}
|
||||
}
|
||||
|
||||
type AccountUtil struct {
|
||||
createAccountParams CreateAccountParams
|
||||
updateAccountParams UpdateAccountParams
|
||||
|
||||
@@ -8,6 +8,19 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type GrantUtil struct {
|
||||
createGrantParams CreateGrantParams
|
||||
updateGrantParams UpdateGrantParams
|
||||
getGrantParams GetGrantParams
|
||||
deleteGrantParams DeleteGrantParams
|
||||
listGrantsParams ListGrantsParams
|
||||
commonGrantParams CommonGrantParams
|
||||
}
|
||||
|
||||
func NewGrantUtil() *GrantUtil {
|
||||
return &GrantUtil{}
|
||||
}
|
||||
|
||||
func (util *GrantUtil) MakeGrantCmds() *cobra.Command {
|
||||
var subCmd = &cobra.Command{
|
||||
Use: "grants",
|
||||
@@ -79,15 +92,6 @@ func (util *GrantUtil) MakeGrantCmds() *cobra.Command {
|
||||
return subCmd
|
||||
}
|
||||
|
||||
type GrantUtil struct {
|
||||
createGrantParams CreateGrantParams
|
||||
updateGrantParams UpdateGrantParams
|
||||
getGrantParams GetGrantParams
|
||||
deleteGrantParams DeleteGrantParams
|
||||
listGrantsParams ListGrantsParams
|
||||
commonGrantParams CommonGrantParams
|
||||
}
|
||||
|
||||
type CommonGrantParams struct {
|
||||
Username string
|
||||
Password string
|
||||
|
||||
@@ -11,6 +11,23 @@ import (
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
type FileUtil struct {
|
||||
fileInfoParams FileInfoParams
|
||||
putFileParams PutFileParams
|
||||
getFileParams GetFileParams
|
||||
deleteFileParams DeleteFileParams
|
||||
listFilesParams ListFilesParams
|
||||
importFilesParams ImportFilesParams
|
||||
exportFilesParams ExportFilesParams
|
||||
deleteCollectionParams DeleteCollectionParams
|
||||
listCollectionsParams ListCollectionsParams
|
||||
commonFileParams CommonFileParams
|
||||
}
|
||||
|
||||
func NewFileUtil() *FileUtil {
|
||||
return &FileUtil{}
|
||||
}
|
||||
|
||||
func (util *FileUtil) MakeFileCmds() *cobra.Command {
|
||||
var subCmd = &cobra.Command{
|
||||
Use: "files",
|
||||
@@ -152,19 +169,6 @@ func (util *FileUtil) MakeCollectionCmds() *cobra.Command {
|
||||
return subCmd
|
||||
}
|
||||
|
||||
type FileUtil struct {
|
||||
fileInfoParams FileInfoParams
|
||||
putFileParams PutFileParams
|
||||
getFileParams GetFileParams
|
||||
deleteFileParams DeleteFileParams
|
||||
listFilesParams ListFilesParams
|
||||
importFilesParams ImportFilesParams
|
||||
exportFilesParams ExportFilesParams
|
||||
deleteCollectionParams DeleteCollectionParams
|
||||
listCollectionsParams ListCollectionsParams
|
||||
commonFileParams CommonFileParams
|
||||
}
|
||||
|
||||
type CommonFileParams struct {
|
||||
Username string
|
||||
Password string
|
||||
|
||||
@@ -13,22 +13,18 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func packUserinfo(resurseuri, username, password string) (string, error) {
|
||||
var err error
|
||||
var res string
|
||||
if !strings.Contains(resurseuri, "://") {
|
||||
resurseuri = "https://" + resurseuri
|
||||
}
|
||||
uri, err := url.Parse(resurseuri)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
uri.Path = path.Clean(uri.Path)
|
||||
if username != "" && password != "" {
|
||||
uri.User = url.UserPassword(username, password)
|
||||
}
|
||||
res = uri.String()
|
||||
return res, err
|
||||
type ImageUtil struct {
|
||||
imageManifestParams ImageManifestParams
|
||||
imageTagsParams ImageTagsParams
|
||||
catalogImagesParams CatalogImagesParams
|
||||
pullImageParams PullImageParams
|
||||
pushImageParams PushImageParams
|
||||
deleteImageParams DeleteImageParams
|
||||
commonImageParams CommonImageParams
|
||||
}
|
||||
|
||||
func NewImageUtil() *ImageUtil {
|
||||
return &ImageUtil{}
|
||||
}
|
||||
|
||||
func (util *ImageUtil) CreateImageCmds() *cobra.Command {
|
||||
@@ -114,20 +110,27 @@ func (util *ImageUtil) CreateImageCmds() *cobra.Command {
|
||||
return subCmd
|
||||
}
|
||||
|
||||
type ImageUtil struct {
|
||||
imageManifestParams ImageManifestParams
|
||||
imageTagsParams ImageTagsParams
|
||||
catalogImagesParams CatalogImagesParams
|
||||
|
||||
pullImageParams PullImageParams
|
||||
pushImageParams PushImageParams
|
||||
deleteImageParams DeleteImageParams
|
||||
commonImageParams CommonImageParams
|
||||
}
|
||||
|
||||
type CommonImageParams struct {
|
||||
Timeout uint64
|
||||
Username string
|
||||
Password string
|
||||
SkipTLSVerify bool
|
||||
}
|
||||
|
||||
func packUserinfo(resurseuri, username, password string) (string, error) {
|
||||
var err error
|
||||
var res string
|
||||
if !strings.Contains(resurseuri, "://") {
|
||||
resurseuri = "https://" + resurseuri
|
||||
}
|
||||
uri, err := url.Parse(resurseuri)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
uri.Path = path.Clean(uri.Path)
|
||||
if username != "" && password != "" {
|
||||
uri.User = url.UserPassword(username, password)
|
||||
}
|
||||
res = uri.String()
|
||||
return res, err
|
||||
}
|
||||
|
||||
+12
-11
@@ -16,12 +16,6 @@ import (
|
||||
)
|
||||
|
||||
type Util struct {
|
||||
// TODO: delete mixed object and use simple object?
|
||||
accountcmd.AccountUtil
|
||||
filecmd.FileUtil
|
||||
imagecmd.ImageUtil
|
||||
accountcmd.GrantUtil
|
||||
|
||||
rootCmd *cobra.Command
|
||||
}
|
||||
|
||||
@@ -43,11 +37,18 @@ func (util *Util) Build() error {
|
||||
}
|
||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
|
||||
rootCmd.AddCommand(util.MakeFileCmds())
|
||||
rootCmd.AddCommand(util.MakeCollectionCmds())
|
||||
rootCmd.AddCommand(util.CreateImageCmds())
|
||||
rootCmd.AddCommand(util.MakeAccountCmds())
|
||||
rootCmd.AddCommand(util.MakeGrantCmds())
|
||||
fileUtil := filecmd.NewFileUtil()
|
||||
rootCmd.AddCommand(fileUtil.MakeFileCmds())
|
||||
rootCmd.AddCommand(fileUtil.MakeCollectionCmds())
|
||||
|
||||
imageUtil := imagecmd.NewImageUtil()
|
||||
rootCmd.AddCommand(imageUtil.CreateImageCmds())
|
||||
|
||||
accountUtil := accountcmd.NewAccountUtil()
|
||||
rootCmd.AddCommand(accountUtil.MakeAccountCmds())
|
||||
|
||||
grantUtil := accountcmd.NewGrantUtil()
|
||||
rootCmd.AddCommand(grantUtil.MakeGrantCmds())
|
||||
|
||||
util.rootCmd = rootCmd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user