mirror of
https://github.com/labring/sealos.git
synced 2026-09-24 15:46:19 +08:00
feature(main): add cmd feature for main branch (#934)
* feature(main): add cmd feature for main branch * feature(main): add copy link for copy file
This commit is contained in:
@@ -18,6 +18,7 @@ package binary
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -110,25 +111,10 @@ func (d *ImageService) Prune() error {
|
||||
return exec.CmdForPipe("bash", "-c", "buildah rmi --prune")
|
||||
}
|
||||
|
||||
func (d *ImageService) ListImages() ([]types.ImageInfo, error) {
|
||||
data := exec.BashEval("buildah images --json")
|
||||
infos, err := listImage(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return infos, nil
|
||||
}
|
||||
|
||||
func listImage(data string) ([]types.ImageInfo, error) {
|
||||
if data != "" {
|
||||
var outStruct []types.ImageInfo
|
||||
err := json.Unmarshal([]byte(data), &outStruct)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "decode out json from list images failed")
|
||||
}
|
||||
return outStruct, nil
|
||||
}
|
||||
return nil, errors.New("images output is empty")
|
||||
func (d *ImageService) ListImages() error {
|
||||
data, err := exec.RunBashCmd("buildah images")
|
||||
_, _ = os.Stdout.Write([]byte(data))
|
||||
return err
|
||||
}
|
||||
|
||||
func NewImageService() (types.Service, error) {
|
||||
|
||||
Reference in New Issue
Block a user