Skip to content

Commit

Permalink
fix(sdk): container port token is resolved as a number (#6692)
Browse files Browse the repository at this point in the history
## Checklist

- [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [ ] Description explains motivation and solution
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
eladcon authored Jun 13, 2024
1 parent a80272e commit 40d5a73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions examples/tests/sdk_tests/container/network.test.w
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ if util.env("WING_TARGET") == "sim" {
args: ["-text=bang"],
network: "host",
) as "network-host";

let localUrl = "http://localhost:{networkHost.hostPort!}";

test "container with host network" {
expect.equal(networkHost.hostPort, "5678");
expect.equal(localUrl, "http://localhost:5678");
}
}
4 changes: 2 additions & 2 deletions libs/wingsdk/src/target-sim/container.inflight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class Container implements IContainerClient, ISimulatorResourceInstance {
LogLevel.VERBOSE
);

let hostPort: number | undefined;
let hostPort: string | undefined;
await waitUntil(async () => {
if (!this.child?.running) {
throw new Error(`Container ${this.imageTag} stopped unexpectedly`);
Expand All @@ -154,7 +154,7 @@ export class Container implements IContainerClient, ISimulatorResourceInstance {
if (this.props.containerPort) {
// when using the host network, the host port is the same as the container port
if (this.props.network === "host") {
hostPort = this.props.containerPort;
hostPort = this.props.containerPort.toString();
return (
container?.[0]?.Config?.ExposedPorts?.[`${hostPort}/tcp`] !==
undefined
Expand Down

0 comments on commit 40d5a73

Please sign in to comment.