feat(ports): add ports command to list and check host port bindings#514
Open
jongio wants to merge 1 commit into
Open
feat(ports): add ports command to list and check host port bindings#514jongio wants to merge 1 commit into
jongio wants to merge 1 commit into
Conversation
Add `azd app ports` to list the host port each service binds, resolved from azure.yaml. Explicit host ports show as their number, auto-assigned ports show as `auto`, and duplicate explicit bindings are flagged with a warning and a non-zero exit so it works as a preflight check before run. Reuses the existing port model (GetPortMappings/ParsePortSpec) so protocol suffixes, ip:host:container forms, and Docker auto-assign resolve the same way run sees them. Adds table-driven unit tests and docs. Closes #509 Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
azd app ports, a read-only command that lists the host port each service binds, resolved from azure.yaml.For every service it prints each binding as
host -> container/protocol. An explicit host port shows as its number; a port left for the runtime to assign shows asauto. When two bindings claim the same explicit host port, the command marks the conflict, prints a warning, and exits non-zero. That makes it a quick preflight check beforeazd app runand lets it gate a pipeline in CI.Why
There is no fast way to see, across all services, which host ports are claimed and whether two services collide on the same one until
runfails to bind. Listing the resolved ports up front, and failing on duplicate explicit bindings, catches the collision before startup.Usage
Text output:
Details
GetPortMappings,ParsePortSpec) so protocol suffixes,ip:host:containerforms, and Docker auto-assign all resolve the same wayrunsees them.Tests
Table-driven unit tests cover the basic report, cross-service conflict, auto ports never conflicting, intra-service duplicate, UDP protocol, JSON shape, and the conflict summary and helper functions.
Verification
go build ./...cleango vet ./src/cmd/app/commands/...cleango test ./src/cmd/app/commands/cleangolangci-lint run ./src/cmd/app/commands/...reports 0 issuesCloses #509