Skip to content

Conversation

@cdalar
Copy link
Owner

@cdalar cdalar commented Nov 2, 2025

No description provided.

…ructure

- Introduced development guidelines in `onctl-development.md` for Go best practices, error handling, testing, and CLI design patterns.
- Updated `AGENTS.md` to include the new guidelines.
- Enhanced `create`, `destroy`, `list`, `ssh`, and `vm` commands by registering them at the root level for easier access.
- Implemented `deploy` command for deploying Docker images to remote VMs with progress tracking and architecture compatibility checks.
- Improved error handling and logging in various commands and internal functions.
- Added support for environment management with `env` command, allowing creation and destruction of environments from template files.
@cdalar cdalar requested a review from Copilot November 2, 2025 12:22
@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

❌ Patch coverage is 13.50211% with 410 lines in your changes missing coverage. Please review.
✅ Project coverage is 10.23%. Comparing base (e07768c) to head (04fdf8a).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
cmd/deploy.go 8.57% 252 Missing and 4 partials ⚠️
internal/cloud/azure.go 0.00% 55 Missing ⚠️
internal/tools/scp.go 37.50% 29 Missing and 6 partials ⚠️
cmd/env.go 20.58% 27 Missing ⚠️
internal/provideraws/common.go 0.00% 19 Missing ⚠️
internal/providerazure/common.go 0.00% 8 Missing ⚠️
internal/cloud/hetzner.go 0.00% 4 Missing ⚠️
internal/tools/remote-run.go 25.00% 3 Missing ⚠️
cmd/common.go 0.00% 1 Missing and 1 partial ⚠️
cmd/root.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##            main     #732      +/-   ##
=========================================
+ Coverage   9.08%   10.23%   +1.15%     
=========================================
  Files         32       35       +3     
  Lines       2521     2970     +449     
=========================================
+ Hits         229      304      +75     
- Misses      2268     2627     +359     
- Partials      24       39      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 refactors the CLI command structure and adds new features including a deploy command, environment management, VM type configuration, and improved file transfer capabilities. The changes focus on better code organization, enhanced user experience with progress tracking, and more flexible cloud resource management.

  • Reorganized CLI commands under vm and env parent commands for better structure
  • Added deploy command for Docker image deployment to remote VMs with architecture validation
  • Enhanced file transfer with progress reporting for SCP operations

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/tools/scp.go Added progress callback support for file transfers and new SCP-based transfer method
internal/tools/remote-run.go Fixed EOF error handling in session cleanup
internal/provideraws/common.go Updated AWS image selection to support wildcards and dynamic image configuration
internal/cloud/hetzner.go Added support for VM type override from configuration
internal/cloud/cloud.go Added YAML tag to VM Type field for config file support
cmd/vm.go New parent command for VM management subcommands
cmd/ssh.go Registered ssh command at root level for backward compatibility
cmd/root.go Removed direct command registration (moved to subcommands)
cmd/list.go Registered list command at root level for backward compatibility
cmd/env.go New environment management command with create/destroy subcommands
cmd/destroy.go Registered destroy command at root level for backward compatibility
cmd/deploy.go New Docker deployment command with architecture validation and progress tracking
cmd/create.go Registered create command at root level for backward compatibility
cmd/common.go Added VM type merging in config merge function
AGENTS.md Updated development guidelines with comprehensive Go best practices
.clinerules/onctl-development.md New development guidelines file (duplicate of AGENTS.md)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

if readErr != nil {
if readErr.Error() == "EOF" {
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

Comparing error strings is fragile and not idiomatic Go. Use errors.Is(readErr, io.EOF) or direct comparison readErr == io.EOF instead. This requires importing the io package.

Copilot uses AI. Check for mistakes.
return err
}
defer os.Remove(tmpKeyFile.Name())
defer tmpKeyFile.Close()
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The file is closed twice: once with defer tmpKeyFile.Close() at line 163 and again explicitly at line 169. The explicit close at line 169 will succeed, but the deferred close will return an error for closing an already-closed file. Remove the defer statement and keep only the explicit close with error handling.

Suggested change
defer tmpKeyFile.Close()

Copilot uses AI. Check for mistakes.
Comment on lines 397 to 405
for i := 0; i < len(result.Images)-1; i++ {
for j := i + 1; j < len(result.Images); j++ {
if result.Images[i].CreationDate != nil && result.Images[j].CreationDate != nil {
if *result.Images[i].CreationDate < *result.Images[j].CreationDate {
result.Images[i], result.Images[j] = result.Images[j], result.Images[i]
}
}
}
}
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

Using bubble sort with O(n²) complexity for sorting images is inefficient. Use Go's built-in sort.Slice() function for O(n log n) performance: sort.Slice(result.Images, func(i, j int) bool { return *result.Images[i].CreationDate > *result.Images[j].CreationDate })

Copilot uses AI. Check for mistakes.
remoteImagePath := "image.tar.gz"

// Upload using SCP
err = remote.SCPCopyFileWithProgress(imageTarPath, remoteImagePath, progressCallback)
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The comment at line 187-188 states 'we'll use a polling approach since scp doesn't have built-in progress reporting', but the implementation doesn't actually poll for progress. It only reports completion after the transfer finishes. Update the comment to reflect the actual implementation or implement true progress polling.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

cdalar and others added 3 commits November 2, 2025 13:27
@cdalar cdalar requested a review from Copilot November 3, 2025 10:04
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

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

cmd/common.go:130

  • The comment states 'will use this function in the future', but the function is already being used in cmd/destroy.go and cmd/env.go. The lint ignore comment and documentation should be updated to reflect current usage.
//lint:ignore U1000 will use this function in the future
func yesNo() bool {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +163 to +167
defer func() {
if removeErr := os.Remove(tmpKeyFile.Name()); removeErr != nil {
log.Printf("Warning: failed to remove temporary key file: %v", removeErr)
}
}()
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Temporary key file cleanup only logs warnings on failure, which could leave sensitive private keys on disk. Consider using a more robust cleanup mechanism or at least ensuring the file is removed before the function returns, possibly by attempting removal multiple times or using os.RemoveAll for more aggressive cleanup.

Copilot uses AI. Check for mistakes.
Comment on lines 392 to 393
progressCallback := func(current, total int64) {
percentage := float64(current) / float64(total) * 100
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Division by zero can occur if total is 0 (e.g., empty file). Add a guard condition to check if total > 0 before calculating percentage.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

@cdalar cdalar marked this pull request as ready for review November 3, 2025 20:43
@cdalar cdalar requested a review from Copilot November 3, 2025 20:44
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

Copilot reviewed 25 out of 25 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

Copilot AI commented Nov 8, 2025

@cdalar I've opened a new pull request, #735, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Nov 8, 2025

@cdalar I've opened a new pull request, #736, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@CLAassistant
Copy link

CLAassistant commented Nov 10, 2025

CLA assistant check
All committers have signed the CLA.

* Initial plan

* fix: add guard condition to prevent division by zero in upload progress callback

Co-authored-by: cdalar <62673+cdalar@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cdalar <62673+cdalar@users.noreply.github.com>
@cdalar cdalar enabled auto-merge (squash) November 10, 2025 21:05
@cdalar cdalar disabled auto-merge November 10, 2025 21:09
@cdalar cdalar merged commit 35144a9 into main Nov 10, 2025
14 checks passed
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.

3 participants