-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/ssh config #37
base: main
Are you sure you want to change the base?
Feat/ssh config #37
Conversation
WalkthroughWalkthroughThe recent updates introduce a dynamic port configuration for the server, allowing users to specify the port via a command-line flag. This enhancement affects the server initialization, the command execution flow, and the TUI (Text User Interface) module to support window resizing. The changes also include updating tests and the integration of the Changes
Sequence DiagramsNew Server Initialization FlowsequenceDiagram
participant User
participant RootCmd
participant ServerCmd
participant StartServer
User->>RootCmd: Execute command with --port flag
RootCmd->>ServerCmd: Pass port flag value
ServerCmd->>StartServer: Call with serverPort parameter
StartServer->>Server: Start server on specified port
Updated Command Execution FlowsequenceDiagram
participant User
participant ServerCmd
participant ssh_config
participant executeRemoteCommand
participant RemoteServer
User->>ServerCmd: Execute remote command
ServerCmd->>ssh_config: Obtain sshPort
ServerCmd->>executeRemoteCommand: Call with required parameters
executeRemoteCommand->>RemoteServer: Execute command on remote server
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range, codebase verification and nitpick comments (2)
cmd/server.go (1)
30-33
: Clarify the description for theport
flag.The description for the
port
flag is a bit unclear. Simplify and clarify it for better understanding.- serverCmd.PersistentFlags().StringVarP(&serverPort, "port", "p", "2222", "Specify the port number to use for connecting to the server. This option allows you to override the default port, which 2222.") + serverCmd.PersistentFlags().StringVarP(&serverPort, "port", "p", "2222", "Specify the port number for the server (default: 2222).")utils/tui/modelutils/file.go (1)
Line range hint
26-52
:
Handle errors inInitialModel
more gracefully.The
InitialModel
function should handle errors more gracefully and provide meaningful messages.func InitialModel(currentDir string, windowHeight int, windowWidth int) FilesSelector { var filesAndDir []string selectedFilesAndDir := make(map[int]bool) entries, err := os.ReadDir(currentDir) if err != nil { return FilesSelector{Error: fmt.Errorf("error reading directory '%s': %w", currentDir, err)} } for _, entry := range entries { entryPath, err := GetPathOfEntry(entry, currentDir) if err != nil { return FilesSelector{Error: fmt.Errorf("error getting path of entry '%s': %w", entry.Name(), err)} } filesAndDir = append(filesAndDir, entryPath) } for i := 0; i < len(filesAndDir); i++ { selectedFilesAndDir[i] = false } return FilesSelector{ CurrentDir: currentDir, FilesAndDir: filesAndDir, SelectedFilesAndDir: selectedFilesAndDir, WindowHeight: windowHeight, WindowWidth: windowWidth, } }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
Files selected for processing (7)
- cmd/root.go (3 hunks)
- cmd/server.go (2 hunks)
- go.mod (1 hunks)
- utils/server/server.go (1 hunks)
- utils/tui/model_test.go (7 hunks)
- utils/tui/modelutils/file.go (5 hunks)
- utils/tui/modelutils/file_test.go (14 hunks)
Files skipped from review due to trivial changes (1)
- go.mod
Additional context used
golangci-lint
utils/server/server.go
[warning] 34-34: exported: exported function StartServer should have comment or be unexported
(revive)
utils/tui/modelutils/file.go
123-123: (*FilesSelector).doResize - result 0 (github.com/charmbracelet/bubbletea.Cmd) is always nil
(unparam)
Additional comments not posted (12)
utils/server/server.go (1)
40-47
: Ensure error handling for window dimensions.The
InitialModel
function initializesFilesSelector
with window dimensions. Ensure that these dimensions are valid and handle any potential errors.Is there a guarantee that
pty.Window.Height
andpty.Window.Width
will always have valid values? If not, consider adding error handling for invalid dimensions.cmd/server.go (3)
16-16
: Verify the new dependency.The
github.com/kevinburke/ssh_config
package has been added. Ensure this dependency is necessary and correctly integrated.Confirm that
ssh_config
is the best choice for handling SSH configuration. If there are alternatives, consider their pros and cons.
27-27
: EnsureserverPort
is validated.The
serverPort
variable should be validated to ensure it contains a valid port number before passing it toStartServer
.Ensure that
serverPort
is always a valid port number. Consider adding validation logic if it is not already handled.
39-55
: Ensure robust handling ofremotePath
formats.The
executeRemoteCommand
function handles differentremotePath
formats. Ensure all edge cases are covered and errors are handled gracefully.Confirm that all possible formats of
remotePath
are handled. Consider adding more test cases to cover edge cases.utils/tui/modelutils/file.go (1)
23-23
: EnsureWindowWidth
is initialized correctly.The
WindowWidth
field has been added to theFilesSelector
struct. Ensure it is always initialized correctly.Confirm that
WindowWidth
is always set to a valid value during initialization.utils/tui/modelutils/file_test.go (1)
141-141
: Ensure comprehensive test coverage.Ensure that the test cases cover all edge cases for the
InitialModel
function, including invalid directory paths and edge cases for window dimensions.Consider adding more test cases to cover edge cases for
InitialModel
.cmd/root.go (2)
24-24
: LGTM!The
port
variable is correctly declared to allow port configuration.
66-66
: LGTM!The
port
flag is correctly added torootCmd.PersistentFlags()
to allow users to specify the port number for SSH connections.utils/tui/model_test.go (4)
16-16
: LGTM!The
InitialModel
function call is correctly updated to include thewindowWidth
parameter in theInit
test case.
35-35
: LGTM!The
InitialModel
function calls are correctly updated to include thewindowWidth
parameter in theUpdate
test cases.Also applies to: 54-54, 72-72
159-159
: LGTM!The
InitialModel
function calls are correctly updated to include thewindowWidth
parameter in theModeSelection
test cases.Also applies to: 177-177
427-427
: LGTM!The
InitialModel
function call is correctly updated to include thewindowWidth
parameter in theView
test case.
Add possibility to specify port for ssh connection and allows to use ssh_config
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Dependencies
github.com/kevinburke/ssh_config v1.2.0
for improved SSH configuration handling.