Skip to content

Conversation

Horiodino
Copy link
Contributor

Fixes #2962

Changes

  • Added --port-forward CLI flag to limactl create, allowing users to specify static port forwards even in plain mode.
  • Modified host agent to set up static SSH-based TCP port forwarding in plain mode.
  • Updated YAML expressions to handle portForwards from CLI.
  • Added validation warnings for large port ranges in plain mode.

Copy link
Member

@nirs nirs left a comment

Choose a reason for hiding this comment

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

It is not clear what is the suggested behavior. Can we start with the documentation instead of the code, so we have clear understanding of wanted behavior?

@Horiodino Horiodino force-pushed the port-forwarding branch 2 times, most recently from 9dfcee3 to d907638 Compare July 11, 2025 17:58
@alexandear alexandear requested a review from Copilot July 12, 2025 16:50
Copy link

@Copilot 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

Adds support for user-defined static port forwarding in plain mode by extending the CLI, YAML schema, host agent logic, and validation.

  • Introduce a --port-forward flag with parsing and YQ expression generation
  • Extend PortForward with Static, filter non-static rules in plain mode, and warn on large port ranges
  • Update host agent to separate/apply static forwards and add end-to-end tests + CI jobs

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/portfwd/forward.go Skip dynamic forwarding for statically handled ports
pkg/limayaml/validate.go Warn for port ranges >10 in plain mode
pkg/limayaml/limayaml.go Add Static field to PortForward struct
pkg/limayaml/defaults.go Remove non-static forwards when plain mode is enabled
pkg/limayaml/defaults_test.go Tests for filtering static vs. non-static forwards
pkg/hostagent/hostagent.go Separate and apply static forwards; adjust event loop logic
cmd/limactl/editflags/editflags.go Register port-forward flag and implement parsing & expression
cmd/limactl/editflags/editflags_test.go Unit tests for ParsePortForward and BuildPortForwardExpression
hack/test-templates/static-port-forward.yaml Template covering static/dynamic port examples
hack/test-plain-static-port-forward.sh Script to verify static-only forwarding in plain mode
hack/test-nonplain-static-port-forward.sh Script to verify full forwarding in normal mode
.github/workflows/test.yml CI jobs to run the new static port forwarding tests
Comments suppressed due to low confidence (2)

pkg/hostagent/hostagent.go:619

  • [nitpick] Consider adding unit or integration tests for separateStaticPortForwards and addStaticPortForwardsFromList to verify correct separation and application of static port-forwarding rules.
func (a *HostAgent) addStaticPortForwardsFromList(ctx context.Context, staticPortForwards []limayaml.PortForward) {

pkg/hostagent/hostagent.go:642

  • The loop uses for i := range len(a.instConfig.PortForwards), which attempts to range over an int and will not compile. Change it to for i := range a.instConfig.PortForwards or use a classic indexed loop like for i := 0; i < len(...); i++.
	for i := range len(a.instConfig.PortForwards) {

@Horiodino Horiodino force-pushed the port-forwarding branch 2 times, most recently from c4cea4c to 5f856c3 Compare July 13, 2025 08:58
@Horiodino Horiodino force-pushed the port-forwarding branch 2 times, most recently from 0599df3 to 9764a70 Compare July 14, 2025 13:47
@AkihiroSuda
Copy link
Member

Needs rebase

@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Aug 18, 2025
@AkihiroSuda
Copy link
Member

@Horiodino Could you rebase?

Signed-off-by: Praful Khanduri <holiodin@gmail.com>
Signed-off-by: Praful Khanduri <99384392+Horiodino@users.noreply.github.com>
Signed-off-by: Praful Khanduri <holiodin@gmail.com>

resolve merge conflicts

Signed-off-by: Praful Khanduri <99384392+Horiodino@users.noreply.github.com>
@Horiodino Horiodino marked this pull request as ready for review August 29, 2025 16:01
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.

Plain mode: support port forwarding (opt-in)
5 participants