Custom name for generate VMs

This commit is contained in:
Mikhail Klementev 2019-12-30 13:58:18 +00:00
parent cc92ec3e23
commit 9c6b8a0122
No known key found for this signature in database
GPG Key ID: BE44DA8C062D87DC
2 changed files with 10 additions and 3 deletions

View File

@ -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":

View File

@ -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)