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")
|
generateCommand := kingpin.Command("generate", "Generate appvm definition")
|
||||||
generateName := generateCommand.Arg("name", "Nix package name").Required().String()
|
generateName := generateCommand.Arg("name", "Nix package name").Required().String()
|
||||||
generateBin := generateCommand.Arg("bin", "Binary").Default("").String()
|
generateBin := generateCommand.Arg("bin", "Binary").Default("").String()
|
||||||
|
generateVMName := generateCommand.Flag("vm", "Use VM Name").Default("").String()
|
||||||
|
|
||||||
switch kingpin.Parse() {
|
switch kingpin.Parse() {
|
||||||
case "list":
|
case "list":
|
||||||
list(l)
|
list(l)
|
||||||
case "generate":
|
case "generate":
|
||||||
generate(l, *generateName, *generateBin)
|
generate(l, *generateName, *generateBin, *generateVMName)
|
||||||
case "start":
|
case "start":
|
||||||
start(l, *startName, *startVerbose)
|
start(l, *startName, *startVerbose)
|
||||||
case "stop":
|
case "stop":
|
||||||
|
10
generate.go
10
generate.go
@ -42,7 +42,7 @@ func nixPath(name string) (path string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func generate(l *libvirt.Libvirt, name, bin string) {
|
func generate(l *libvirt.Libvirt, name, bin, vmname string) {
|
||||||
if !isPackageExists(name) {
|
if !isPackageExists(name) {
|
||||||
log.Println("Package pkgs."+name, "does not exists")
|
log.Println("Package pkgs."+name, "does not exists")
|
||||||
return
|
return
|
||||||
@ -88,7 +88,13 @@ func generate(l *libvirt.Libvirt, name, bin string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
realName := strings.Split(name, ".")[1]
|
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)
|
appNixConfig := fmt.Sprintf(template, realName, bin)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user