-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): network and entrypoint options for
sim.Container
(#6667)
## 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
Showing
13 changed files
with
234 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,5 +36,5 @@ if util.env("WING_TARGET") == "sim" { | |
log(response.body); | ||
expect.equal("Hello, Wingnuts!", response.body); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*\ | ||
skipPlatforms: | ||
- win32 | ||
- darwin | ||
\*/ | ||
|
||
bring sim; | ||
bring http; | ||
bring util; | ||
bring expect; | ||
|
||
// only relevant in simulator | ||
if util.env("WING_TARGET") == "sim" { | ||
let entrypoint = new sim.Container( | ||
name: "my-entrypoint-app", | ||
image: "./my-docker-image", | ||
containerPort: 3000, | ||
args: ["-c", "RESPONSE=hello /usr/local/bin/node /app/index.js"], | ||
entrypoint: "/bin/sh", | ||
) as "with-entrypoint"; | ||
|
||
test "container with entrypoint" { | ||
let response = http.get("http://localhost:{entrypoint.hostPort!}"); | ||
log(response.body); | ||
expect.equal("hello", response.body); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*\ | ||
skipPlatforms: | ||
- win32 | ||
- darwin | ||
\*/ | ||
|
||
bring sim; | ||
bring http; | ||
bring util; | ||
bring expect; | ||
|
||
// only relevant in simulator | ||
if util.env("WING_TARGET") == "sim" { | ||
let networkHost = new sim.Container( | ||
name: "http-echo", | ||
image: "hashicorp/http-echo", | ||
containerPort: 5678, | ||
args: ["-text=bang"], | ||
network: "host", | ||
) as "network-host"; | ||
|
||
test "container with host network" { | ||
expect.equal(networkHost.hostPort, "5678"); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
21 changes: 21 additions & 0 deletions
21
...snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_compile_tf-aws.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# [entrypoint.test.w](../../../../../../examples/tests/sdk_tests/container/entrypoint.test.w) | compile | tf-aws | ||
|
||
## main.tf.json | ||
```json | ||
{ | ||
"//": { | ||
"metadata": { | ||
"backend": "local", | ||
"stackName": "root", | ||
"version": "0.20.3" | ||
}, | ||
"outputs": {} | ||
}, | ||
"provider": { | ||
"aws": [ | ||
{} | ||
] | ||
} | ||
} | ||
``` | ||
|
14 changes: 14 additions & 0 deletions
14
...gar/__snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_test_sim.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# [entrypoint.test.w](../../../../../../examples/tests/sdk_tests/container/entrypoint.test.w) | test | sim | ||
|
||
## stdout.log | ||
```log | ||
[INFO] container with entrypoint | hello | ||
[WARNING] container with entrypoint | Timeout waiting for container root/env0/with-entrypoint to shutdown, removing forcefully | ||
pass ─ entrypoint.test.wsim » root/env0/test:container with entrypoint | ||
Tests 1 passed (1) | ||
Snapshots 1 skipped | ||
Test Files 1 passed (1) | ||
Duration <DURATION> | ||
``` | ||
|
21 changes: 21 additions & 0 deletions
21
.../__snapshots__/test_corpus/sdk_tests/container/network.test.w_compile_tf-aws.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# [network.test.w](../../../../../../examples/tests/sdk_tests/container/network.test.w) | compile | tf-aws | ||
|
||
## main.tf.json | ||
```json | ||
{ | ||
"//": { | ||
"metadata": { | ||
"backend": "local", | ||
"stackName": "root", | ||
"version": "0.20.3" | ||
}, | ||
"outputs": {} | ||
}, | ||
"provider": { | ||
"aws": [ | ||
{} | ||
] | ||
} | ||
} | ||
``` | ||
|
12 changes: 12 additions & 0 deletions
12
...hangar/__snapshots__/test_corpus/sdk_tests/container/network.test.w_test_sim.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# [network.test.w](../../../../../../examples/tests/sdk_tests/container/network.test.w) | test | sim | ||
|
||
## stdout.log | ||
```log | ||
pass ─ network.test.wsim » root/env0/test:container with host network | ||
Tests 1 passed (1) | ||
Snapshots 1 skipped | ||
Test Files 1 passed (1) | ||
Duration <DURATION> | ||
``` | ||
|