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