Skip to content

Commit 0ee5ea3

Browse files
committed
feat: update to latest gateway
1 parent 94b6ec4 commit 0ee5ea3

File tree

4 files changed

+28
-34
lines changed

4 files changed

+28
-34
lines changed

.github/workflows/integration-gateway.yml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,8 @@ jobs:
2626

2727
- uses: ./.github/actions/setup-poetry
2828

29-
- name: Create gateway database
30-
run: |
31-
poetry run scwgw create-db
32-
poetry run scwgw await-db
33-
34-
- name: Create gateway namespace
35-
run: |
36-
poetry run scwgw create-namespace
37-
poetry run scwgw await-namespace
38-
39-
- name: Create gateway container
40-
run: |
41-
poetry run scwgw create-containers
42-
poetry run scwgw await-containers
29+
- name: Deploy Serverless Gateway
30+
run: poetry run scwgw deploy
4331

4432
run-tests:
4533
needs:
@@ -71,8 +59,5 @@ jobs:
7159

7260
- uses: ./.github/actions/setup-poetry
7361

74-
- name: Delete namespace
75-
run: poetry run scwgw delete-namespace
76-
77-
- name: Delete database
78-
run: poetry run scwgw delete-db
62+
- name: Delete Serverless Gateway
63+
run: poetry run scwgw delete

poetry.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pytest-xdist = "^3.1.0"
4747
pylint = "^2.15.10"
4848
pylint-per-file-ignores = "^1.1.0"
4949
responses = ">=0.22,<0.24"
50-
scw-gateway = "^0.2.0"
50+
scw-gateway = "^0.3.0"
5151

5252
[tool.poetry.group.doc]
5353
optional = true

scw_serverless/gateway/serverless_gateway.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ def __init__(self) -> None:
2424
raise RuntimeError("scwgw is not installed")
2525
self.cli = cli
2626

27-
# TODO?: run check command
27+
# Verify that the CLI is installed and working
28+
cmd = self._invoke_cli(["check"])
29+
for line in cmd.stdout.splitlines():
30+
if not line.endswith("ready"):
31+
click.secho(f"scwgw is not ready: {line}", fg="red")
32+
raise RuntimeError("scwgw is not ready")
2833

2934
def _invoke_cli(self, args: list[str]) -> subprocess.CompletedProcess:
3035
cmd = subprocess.run(
@@ -33,8 +38,6 @@ def _invoke_cli(self, args: list[str]) -> subprocess.CompletedProcess:
3338
stdout=subprocess.PIPE,
3439
universal_newlines=True,
3540
)
36-
for line in cmd.stdout:
37-
print(line, end="")
3841
return cmd
3942

4043
def add_route(self, route: GatewayRoute) -> None:
@@ -43,4 +46,10 @@ def add_route(self, route: GatewayRoute) -> None:
4346
if not route.target:
4447
raise RuntimeError(f"route {route.relative_url} is missing upstream target")
4548

46-
self._invoke_cli(["add-route", route.relative_url, route.target])
49+
cli_args = ["add-route", route.relative_url, route.target]
50+
for method in route.http_methods or []:
51+
cli_args += ["--http-methods", method.value]
52+
53+
cmd = self._invoke_cli(cli_args)
54+
for char in cmd.stdout:
55+
print(char, end="")

0 commit comments

Comments
 (0)