Skip to content

Conversation

@josh
Copy link

@josh josh commented Sep 22, 2025

Allows a proxmox_storage_iso resource to accept a local path to the iso. Remote HTTP ISOs are automatically fetched first and stored locally in a tmpdir before uploading. This basically skips the download step and uploads any local path as is. Right now this supports absolute paths, but open to having the format be file:/// if we want the value to always be some kind of URI.

resource "proxmox_storage_iso" "ubuntu" {
  url = "/path/to/local/ubuntu.iso"
}

Copilot AI review requested due to automatic review settings September 22, 2025 02:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for using local file paths in the proxmox_storage_iso resource instead of requiring remote HTTP URLs. The enhancement allows users to upload ISO files directly from their local filesystem without needing to host them remotely first.

Key Changes

  • Added conditional logic to detect absolute paths and open them directly
  • Modified file handling to skip the temporary file creation and HTTP download steps for local paths
  • Maintained backward compatibility with existing HTTP URL functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +78 to +83
if filepath.IsAbs(url) {
file, err = os.Open(url)
if err != nil {
return diag.FromErr(err)
}
} else {
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic assumes any absolute path is a local file, but HTTP/HTTPS URLs also contain absolute paths (e.g., 'https://example.com/file.iso'). This will cause HTTP URLs to be treated as local file paths. Consider checking if the URL starts with a scheme like 'http://' or 'https://' instead of using filepath.IsAbs().

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +92
file, err = os.CreateTemp(os.TempDir(), fileName)
if err != nil {
return diag.FromErr(err)
}
err = _downloadFile(url, file)
if err != nil {
return diag.FromErr(err)
}
file.Seek(0, 0)
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temporary file cleanup logic is missing when _downloadFile fails. If the download fails, the temporary file created by os.CreateTemp will not be cleaned up, potentially leaving orphaned files in the temp directory. Consider adding proper cleanup with defer os.Remove(file.Name()) after successful temp file creation.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant