Skip to content

Commit

Permalink
Fixed static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Maarten de Kruijf committed Dec 13, 2023
1 parent b9ae9ec commit abc6a82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 7 additions & 1 deletion proxmox/resource_storage_iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ func resourceStorageIsoCreate(d *schema.ResourceData, meta interface{}) error {

client := pconf.Client
file, err := os.CreateTemp("/tmp", fileName)
if err != nil {
return err
}
err = _downloadFile(url, file)
if err != nil {
return err
}
file.Seek(0, 0)
defer file.Close()
err = client.Upload(node, storage, isoContentType, fileName, file)
Expand All @@ -96,7 +102,7 @@ func _downloadFile(url string, file *os.File) error {
}
defer resp.Body.Close()
_, err = io.Copy(file, resp.Body)
return nil
return err
}

func resourceStorageIsoRead(d *schema.ResourceData, meta interface{}) error {
Expand Down
11 changes: 4 additions & 7 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,16 +1069,15 @@ func resourceVmQemuCreate(ctx context.Context, d *schema.ResourceData, meta inte

forceCreate := d.Get("force_create").(bool)

var targetNodes []string
targetNodesRaw := d.Get("target_nodes").([]interface{})
targetNodes = make([]string, len(targetNodesRaw))
var targetNodes = make([]string, len(targetNodesRaw))
for i, raw := range targetNodesRaw {
targetNodes[i] = raw.(string)
}

var targetNode string

if targetNodes == nil || len(targetNodes) == 0 {
if len(targetNodes) == 0 {
targetNode = d.Get("target_node").(string)
} else {
targetNode = targetNodes[rand.Intn(len(targetNodes))]
Expand Down Expand Up @@ -1668,14 +1667,13 @@ func resourceVmQemuRead(ctx context.Context, d *schema.ResourceData, meta interf

// loop through all virtual servers...?
var targetNodeVMR string = ""
var targetNodes []string
targetNodesRaw := d.Get("target_nodes").([]interface{})
targetNodes = make([]string, len(targetNodesRaw))
var targetNodes = make([]string, len(targetNodesRaw))
for i, raw := range targetNodesRaw {
targetNodes[i] = raw.(string)
}

if targetNodes == nil || len(targetNodes) == 0 {
if len(targetNodes) == 0 {
_, err = client.GetVmInfo(vmr)
if err != nil {
logger.Debug().Int("vmid", vmID).Err(err).Msg("failed to get vm info")
Expand All @@ -1694,7 +1692,6 @@ func resourceVmQemuRead(ctx context.Context, d *schema.ResourceData, meta interf
d.SetId(resourceId(vmr.Node(), "qemu", vmr.VmId()))
logger.Debug().Any("Setting node id to", d.Get(vmr.Node()))
targetNodeVMR = targetNode
break
}
}

Expand Down

0 comments on commit abc6a82

Please sign in to comment.