Skip to content

feat(config): support forwardPorts range syntax expansion#168

Merged
skevetter merged 3 commits into
mainfrom
d226/forward-ports-range
May 3, 2026
Merged

feat(config): support forwardPorts range syntax expansion#168
skevetter merged 3 commits into
mainfrom
d226/forward-ports-range

Conversation

@skevetter

@skevetter skevetter commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds support for port range notation (e.g. 3000-3005) in the devcontainer forwardPorts field, expanding ranges into individual ports during config merging. This enables users to specify ["8080", "3000-3005"] and have all 7 ports forwarded. Invalid ranges (start > end, negative, non-numeric) are rejected gracefully. Includes 14 unit tests covering single ports, ranges, mixed inputs, deduplication across ranges, and error cases, plus an E2E test validating range expansion through read-configuration --include-merged-configuration.

Summary by CodeRabbit

  • New Features

    • Forward ports configuration now supports range syntax notation (e.g., 3000-3005), which automatically expands into individual ports during configuration processing.
  • Tests

    • Added comprehensive end-to-end and unit tests validating port range expansion, deduplication behavior, and configuration merging with mixed port formats.

Parse port range notation like '3000-3005' in forwardPorts and expand to
individual ports [3000, 3001, ..., 3005]. Mixed ranges and single ports
work together; invalid ranges are rejected with clear errors.
@netlify

netlify Bot commented May 3, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit a064e12
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/69f6d32530e2fe00086e812e

@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds port range expansion support to devcontainer configuration merging. Port ranges in forwardPorts (e.g., 3000-3005) are now parsed and expanded into individual port entries during configuration merge, with comprehensive unit and e2e test coverage.

Changes

Port Range Expansion for Forward Ports

Layer / File(s) Summary
Port Range Parsing & Expansion
pkg/devcontainer/config/merge.go
New parsePortRange validates start-end syntax with error checking for non-negative integers and start <= end. expandPortRange expands ranges into individual port strings; entries containing : are passed through unchanged.
Merge Integration
pkg/devcontainer/config/merge.go
mergeForwardPorts updated to call expandPortRange on each entry, skip invalid ranges, and continue using localhost-prefixed deduplication before appending expanded ports to the result.
Unit Tests
pkg/devcontainer/config/merge_test.go
Tests cover range expansion (3000-3002["3000", "3001", "3002"]), single ports and host:port passthrough, mixed inputs, deduplication across overlapping ranges, and skipping of invalid ranges while preserving valid ports.
E2E Test Data
e2e/tests/readconfiguration/testdata-port-range/.devcontainer/devcontainer.json
Devcontainer configuration with forwardPorts set to [8080, "3000-3005"].
E2E Test & Suite Registration
e2e/tests/readconfiguration/readconfiguration.go, e2e/e2e_suite_test.go
E2E test runs read-configuration --include-merged-configuration against the port-range test data and validates that mergedConfiguration.forwardPorts contains the expanded individual ports (8080, 3000, 3001, ..., 3005) with exactly 7 entries. Test suite registers the readconfiguration package via blank import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for port range syntax expansion in forwardPorts configuration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the size/l label May 3, 2026
skevetter added 2 commits May 2, 2026 23:16
Extract parsePortRange helper to reduce expandPortRange cyclomatic
complexity (cyclop), compact TestExpandPortRange with slices.Equal
and inline test cases (funlen), fix continuation-line indentation
(gci/gofumpt), and extract repeated "3000-3002" to testPortRange
const (goconst).
@skevetter
skevetter marked this pull request as ready for review May 3, 2026 05:14
@skevetter
skevetter enabled auto-merge (squash) May 3, 2026 05:14
@skevetter
skevetter merged commit 1c618f1 into main May 3, 2026
50 of 51 checks passed
@skevetter
skevetter deleted the d226/forward-ports-range branch May 3, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant