diff --git a/cmd/mstorectl/imagecmd.go b/cmd/mstorectl/imagecmd.go index 741d09d..e338808 100644 --- a/cmd/mstorectl/imagecmd.go +++ b/cmd/mstorectl/imagecmd.go @@ -1,6 +1,9 @@ package main import ( + "context" + "time" + "mstore/pkg/client" "github.com/spf13/cobra" @@ -84,6 +87,19 @@ func (util *ImageUtil) ImageInfo(cmd *cobra.Command, args []string) { printResponse(res, err) } +func (util *ImageUtil) imageInfo(params *ImageInfoParams) (*ImageInfoResult, error) { + var err error + res := &ImageInfoResult{} + ctx := context.Background() + + cli := client.NewClientWithAuth(params.Username, params.Password) + timeout := time.Duration(params.Timeout) * time.Second + opres, err := cli.ImageInfo(ctx, params.Imagepath, timeout) + + res.ImageInfo = opres + return res, err +} + // PullImage type PullImageParams struct { Imagepath string @@ -100,6 +116,19 @@ func (util *ImageUtil) PullImage(cmd *cobra.Command, args []string) { printResponse(res, err) } +func (util *ImageUtil) pullImage(params *PullImageParams) (*PullImageResult, error) { + var err error + + ctx := context.Background() + res := &PullImageResult{} + + cli := client.NewClientWithAuth(params.Username, params.Password) + timeout := time.Duration(params.Timeout) * time.Second + err = cli.PullImage(ctx, params.Imagepath, params.Filepath, timeout) + + return res, err +} + // PushImage type PushImageParams struct { Imagepath string @@ -115,3 +144,15 @@ func (util *ImageUtil) PushImage(cmd *cobra.Command, args []string) { res, err := util.pushImage(&util.pushImageParams) printResponse(res, err) } + +func (util *ImageUtil) pushImage(params *PushImageParams) (*PushImageResult, error) { + var err error + ctx := context.Background() + res := &PushImageResult{} + + cli := client.NewClientWithAuth(params.Username, params.Password) + timeout := time.Duration(params.Timeout) * time.Second + err = cli.PushImage(ctx, params.Filepath, params.Imagepath, timeout) + + return res, err +} diff --git a/cmd/mstorectl/imageinfo.go b/cmd/mstorectl/imageinfo.go deleted file mode 100644 index 0925505..0000000 --- a/cmd/mstorectl/imageinfo.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import ( - "context" - "time" - - "mstore/pkg/client" -) - -func (util *ImageUtil) imageInfo(params *ImageInfoParams) (*ImageInfoResult, error) { - var err error - res := &ImageInfoResult{} - ctx := context.Background() - - cli := client.NewClientWithAuth(params.Username, params.Password) - timeout := time.Duration(params.Timeout) * time.Second - opres, err := cli.ImageInfo(ctx, params.Imagepath, timeout) - - res.ImageInfo = opres - return res, err -} diff --git a/cmd/mstorectl/imagepull.go b/cmd/mstorectl/imagepull.go deleted file mode 100644 index 6bf1a50..0000000 --- a/cmd/mstorectl/imagepull.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import ( - "context" - "time" - - "mstore/pkg/client" -) - -func (util *ImageUtil) pullImage(params *PullImageParams) (*PullImageResult, error) { - var err error - - ctx := context.Background() - res := &PullImageResult{} - - cli := client.NewClientWithAuth(params.Username, params.Password) - timeout := time.Duration(params.Timeout) * time.Second - err = cli.PullImage(ctx, params.Imagepath, params.Filepath, timeout) - - return res, err -} diff --git a/cmd/mstorectl/imagepush.go b/cmd/mstorectl/imagepush.go deleted file mode 100644 index a590ebb..0000000 --- a/cmd/mstorectl/imagepush.go +++ /dev/null @@ -1,20 +0,0 @@ -package main - -import ( - "context" - "time" - - "mstore/pkg/client" -) - -func (util *ImageUtil) pushImage(params *PushImageParams) (*PushImageResult, error) { - var err error - ctx := context.Background() - res := &PushImageResult{} - - cli := client.NewClientWithAuth(params.Username, params.Password) - timeout := time.Duration(params.Timeout) * time.Second - err = cli.PushImage(ctx, params.Filepath, params.Imagepath, timeout) - - return res, err -}