Skip to content

Commit

Permalink
fix: prevent deletion attempts for non-existent vmID -1
Browse files Browse the repository at this point in the history
Fixes #31.
  • Loading branch information
pborn-ionos committed Dec 16, 2023
1 parent 5f6d700 commit 42cba37
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/proxmox/goproxmox/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ func (c *APIClient) FindVMResource(ctx context.Context, vmID uint64) (*proxmox.C

// DeleteVM deletes a VM based on the nodeName and vmID.
func (c *APIClient) DeleteVM(ctx context.Context, nodeName string, vmID int64) (*proxmox.Task, error) {
// A vmID can not be lower than 100.
// If the provided vmID is lower (like -1 in issue #31), just error out without calling the API.
if vmID < 100 {
return nil, fmt.Errorf("vm with id %d does not exist", vmID)
}

node, err := c.Node(ctx, nodeName)
if err != nil {
return nil, fmt.Errorf("cannot find node with name %s: %w", nodeName, err)
Expand Down

0 comments on commit 42cba37

Please sign in to comment.