54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*
|
|
* This work is published and licensed under a Creative Commons
|
|
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
|
*
|
|
* Distribution of this work is permitted, but commercial use and
|
|
* modifications are strictly prohibited.
|
|
*/
|
|
package imagecmd
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"mstore/pkg/client"
|
|
)
|
|
|
|
// DeleteImage
|
|
type DeleteImageParams struct {
|
|
Imagepath string
|
|
}
|
|
|
|
type DeleteImageResult struct {
|
|
}
|
|
|
|
func (util *ImageUtil) DeleteImage(cmd *cobra.Command, args []string) {
|
|
util.deleteImageParams.Imagepath = args[0]
|
|
res, err := util.deleteImage(&util.commonImageParams, &util.deleteImageParams)
|
|
printResponse(res, err)
|
|
}
|
|
|
|
func (util *ImageUtil) deleteImage(common *CommonImageParams, params *DeleteImageParams) (*DeleteImageResult, error) {
|
|
var err error
|
|
res := &DeleteImageResult{}
|
|
ctx := context.Background()
|
|
|
|
cli := client.NewClient(common.SkipTLSVerify)
|
|
timeout := time.Duration(common.Timeout) * time.Second
|
|
|
|
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
ctx, _ = context.WithTimeout(ctx, timeout)
|
|
err = cli.DeleteImage(ctx, params.Imagepath)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
return res, err
|
|
}
|