Repository: luthermonson/go-proxmox (language: go)

Issue:
Invalid memory address or nil pointer dereference on vm.Delete()
Hi!
Function Delete for VM fails with
```runtime error: invalid memory address or nil pointer dereference```

My code
```
ctx := context.Background()
// Use vm.Status != "stopped" because vm.IsStopped()/vm.IsRunning() always returns 'false'
if vm.Status != "stopped" {
	task, err := vm.Stop(ctx)
	if err != nil {
		log.Error(err)
		return err
	}
	status, completed, err := task.WaitForCompleteStatus(ctx, 10, 3, 5, 10)
	if err != nil {
		return err
	}
	if !status && !completed {
		return fmt.Errorf("cannot stop vm %v", vmid)
	}
}

task, err := vm.Delete(ctx)
if err != nil {
	log.Error(err)
	return err
}
status, completed, err := task.WaitForCompleteStatus(ctx, 10, 3, 5, 10)
if err != nil {
	return err
}
if !status && !completed {
	return fmt.Errorf("cannot delete vm %v", vmid)
}
```
vm.Stop works but vm.Delete fails

```
runtime error: invalid memory address or nil pointer dereference
/usr/lib/go/src/runtime/panic.go:261 (0x450ef7)
        panicmem: panic(memoryError)
/usr/lib/go/src/runtime/signal_unix.go:861 (0x450ec5)
        sigpanic: panicmem()
/home/snels/go/pkg/mod/github.com/luthermonson/go-proxmox@v0.0.0-beta3/virtual_machine.go:54 (0x940e5b)
        (*VirtualMachine).HasTag: if v.VirtualMachineConfig.Tags == "" {
/home/snels/go/pkg/mod/github.com/luthermonson/go-proxmox@v0.0.0-beta3/virtual_machine.go:337 (0x943616)
        (*VirtualMachine).deleteCloudInitISO: if v.HasTag(MakeTag(TagCloudInit)) {
/home/snels/go/pkg/mod/github.com/luthermonson/go-proxmox@v0.0.0-beta3/virtual_machine.go:324 (0x943436)
        (*VirtualMachine).Delete: if ok, err := v.deleteCloudInitISO(ctx); err != nil || !ok {
/home/snels/git/pve-api-gateway/pkg/pve/vm.go:542 (0x952464)
        deleteVM: task, err := vm.Delete(ctx)
```

Am I doing something wrong or is the problem in the module?


Discussion / hints:
how did you make the vm you are making these Delete calls against? because it's complaining that the vm config is nil and that is populated here: https://github.com/luthermonson/go-proxmox/blob/main/nodes.go#L76-L78

did you not make the vm via `node.VirtualMachine(ctx, id)`?

Fix patch:
diff --git a/virtual_machine.go b/virtual_machine.go
index 194b18a..56fa971 100644
--- a/virtual_machine.go
+++ b/virtual_machine.go
@@ -51,6 +51,10 @@ func (v *VirtualMachine) VNCProxy(ctx context.Context) (vnc *VNC, err error) {
 }
 
 func (v *VirtualMachine) HasTag(value string) bool {
+	if v.VirtualMachineConfig == nil {
+		return false
+	}
+
 	if v.VirtualMachineConfig.Tags == "" {
 		return false
 	}


Test patch: