mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2024-11-23 16:41:29 +00:00
Custom name for generate VMs
This commit is contained in:
parent
cc92ec3e23
commit
9c6b8a0122
3
appvm.go
3
appvm.go
|
@ -403,12 +403,13 @@ func main() {
|
|||
generateCommand := kingpin.Command("generate", "Generate appvm definition")
|
||||
generateName := generateCommand.Arg("name", "Nix package name").Required().String()
|
||||
generateBin := generateCommand.Arg("bin", "Binary").Default("").String()
|
||||
generateVMName := generateCommand.Flag("vm", "Use VM Name").Default("").String()
|
||||
|
||||
switch kingpin.Parse() {
|
||||
case "list":
|
||||
list(l)
|
||||
case "generate":
|
||||
generate(l, *generateName, *generateBin)
|
||||
generate(l, *generateName, *generateBin, *generateVMName)
|
||||
case "start":
|
||||
start(l, *startName, *startVerbose)
|
||||
case "stop":
|
||||
|
|
10
generate.go
10
generate.go
|
@ -42,7 +42,7 @@ func nixPath(name string) (path string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func generate(l *libvirt.Libvirt, name, bin string) {
|
||||
func generate(l *libvirt.Libvirt, name, bin, vmname string) {
|
||||
if !isPackageExists(name) {
|
||||
log.Println("Package pkgs."+name, "does not exists")
|
||||
return
|
||||
|
@ -88,7 +88,13 @@ func generate(l *libvirt.Libvirt, name, bin string) {
|
|||
}
|
||||
|
||||
realName := strings.Split(name, ".")[1]
|
||||
appFilename := configDir + "/nix/" + realName + ".nix"
|
||||
|
||||
var appFilename string
|
||||
if vmname != "" {
|
||||
appFilename = configDir + "/nix/" + vmname + ".nix"
|
||||
} else {
|
||||
appFilename = configDir + "/nix/" + realName + ".nix"
|
||||
}
|
||||
|
||||
appNixConfig := fmt.Sprintf(template, realName, bin)
|
||||
|
||||
|
|
Loading…
Reference in a new issue