refactor(tunnel): replace params with RunServicesOptions struct#409
refactor(tunnel): replace params with RunServicesOptions struct#409
Conversation
Signed-off-by: Samuel K <skevetter@pm.me>
📝 WalkthroughWalkthroughThis pull request refactors Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as rgba(30,144,255,0.5) CLI
participant Local as rgba(34,139,34,0.5) LocalProcess
participant Tunnel as rgba(255,165,0,0.5) TunnelServer
participant Remote as rgba(128,0,128,0.5) RemoteCredentialsServer
participant Container as rgba(220,20,60,0.5) Container
CLI->>Local: calls RunServices(ctx, RunServicesOptions)
Local->>Tunnel: startTunnelServer (runTunnelServer)
Local->>Remote: buildCredentialsCommand -> exec remote credentials server
Remote->>Container: request creds / configure git/docker
Tunnel->>Container: establish port forwards (forwardDevContainerPorts -> forwardPort)
Container-->>Remote: container result (ports, status)
Remote-->>Local: exit / error (reported via channels)
Local->>CLI: return error/exit based on retry/backoff and exit timeout
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Samuel K <skevetter@pm.me>
Signed-off-by: Samuel K <skevetter@pm.me>
Signed-off-by: Samuel K <skevetter@pm.me>
Signed-off-by: Samuel K <skevetter@pm.me>
Signed-off-by: Samuel K <skevetter@pm.me>
Signed-off-by: Samuel K <skevetter@pm.me>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@pkg/tunnel/services.go`:
- Around line 300-330: The function forwardConfigPorts can panic if
result.MergedConfig is nil; add a defensive nil-check at the start of
forwardConfigPorts (which takes portForwardParams p and *config2.Result result)
to return an empty []string immediately when result == nil or
result.MergedConfig == nil before accessing result.MergedConfig.ForwardPorts;
keep the existing behavior for parsing via parseForwardPort and async calls to
devssh.PortForward, and ensure any early-return path is consistent with
forwardAppPorts (no further goroutines or appends when nil).
- Around line 286-298: The functions forwardAppPorts and forwardConfigPorts
access result.MergedConfig without checking for nil; add a guard at the start of
each function that returns an empty []string if result == nil ||
result.MergedConfig == nil. Update forwardAppPorts (which iterates
result.MergedConfig.AppPort) and forwardConfigPorts (which reads
result.MergedConfig.ConfigPort) to short-circuit early to avoid nil-pointer
panics, keeping the rest of the logic unchanged.
🧹 Nitpick comments (1)
pkg/tunnel/services.go (1)
196-225: Consider adding more selective retry conditions.The current retry logic retries all errors except context cancellation. This might cause unnecessary retries for permanent failures (e.g., authentication errors, permission denied). Consider filtering out non-transient errors:
}, func(err error) bool { if ctx.Err() != nil { return false } // Consider: check if error is transient (connection reset, timeout, etc.) // and return false for permanent errors return true },However, if the intent is maximum resilience for SSH connection instability, the current approach is acceptable.
Signed-off-by: Samuel K <skevetter@pm.me>
Signed-off-by: Samuel K skevetter@pm.me
Summary by CodeRabbit
Refactor
Bug Fixes / Reliability
Logging