Implements dry run for image edit
This commit is contained in:
parent
bb319a9ff6
commit
4a3d739b85
20
images.go
20
images.go
@ -13,6 +13,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.dumpstack.io/tools/out-of-tree/config"
|
"code.dumpstack.io/tools/out-of-tree/config"
|
||||||
@ -46,7 +47,8 @@ func (cmd *ImageListCmd) Run(g *Globals) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ImageEditCmd struct {
|
type ImageEditCmd struct {
|
||||||
Name string `help:"image name" required:""`
|
Name string `help:"image name" required:""`
|
||||||
|
DryRun bool `help:"do nothing, just print commands"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *ImageEditCmd) Run(g *Globals) (err error) {
|
func (cmd *ImageEditCmd) Run(g *Globals) (err error) {
|
||||||
@ -86,6 +88,22 @@ func (cmd *ImageEditCmd) Run(g *Globals) (err error) {
|
|||||||
|
|
||||||
q.Mutable = true
|
q.Mutable = true
|
||||||
|
|
||||||
|
if cmd.DryRun {
|
||||||
|
s := q.Executable()
|
||||||
|
for _, arg := range q.Args() {
|
||||||
|
if strings.Contains(arg, " ") ||
|
||||||
|
strings.Contains(arg, ",") {
|
||||||
|
|
||||||
|
s += fmt.Sprintf(` "%s"`, arg)
|
||||||
|
} else {
|
||||||
|
s += fmt.Sprintf(" %s", arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Println(s)
|
||||||
|
fmt.Println(q.GetSSHCommand())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = q.Start()
|
err = q.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Qemu start error:", err)
|
fmt.Println("Qemu start error:", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user