Skip to content

Commit ec5fd5e

Browse files
authored
chore: release new serverless gateway integration 🎉 (#117)
* chore: update for gateway CLI changes * docs: fix typo changelog * chore: poetry lock * fix(ci): update workflow for scwgw changes * fix(test): get-endpoint deprecated * docs: typo in variable name * docs: link to readthedocs docs
1 parent c7d33cb commit ec5fd5e

File tree

7 files changed

+45
-32
lines changed

7 files changed

+45
-32
lines changed

.github/workflows/integration-gateway.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: ./.github/actions/setup-poetry
2222

2323
- name: Deploy Serverless Gateway
24-
run: poetry run scwgw deploy
24+
run: poetry run scwgw infra deploy
2525
env:
2626
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
2727
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
@@ -41,7 +41,7 @@ jobs:
4141
- name: Run integration tests
4242
working-directory: tests
4343
run: |
44-
poetry run scwgw remote-config
44+
poetry run scwgw infra config
4545
poetry run pytest integrations/gateway -n $(nproc --all)
4646
env:
4747
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
@@ -64,7 +64,7 @@ jobs:
6464
- uses: ./.github/actions/setup-poetry
6565

6666
- name: Delete Serverless Gateway
67-
run: poetry run scwgw delete -y
67+
run: poetry run scwgw infra delete -y
6868
env:
6969
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
7070
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
### Removed
3939

4040
- Removed generating Terraform and Serverless Framework configuration files as those features were mostly unused. This does not break the `scw-serverless` library but it removes a command from the CLI. We think those changes will help improve the overall quality of the tool.
41+
42+
## [1.2.0] - 2023-07-03
43+
44+
### Feature
45+
46+
- Changed the gateway integration to work with latest release of the Serverless Gateway project

docs/source/gateway.rst

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
API Gateway
22
===========
33

4-
The framework provides support for routed functions via a Gateway container that can be deployed separately.
5-
For more information, please consult the documentation on the `Serverless Gateway repository`_
4+
The framework provides support for routed functions via the Serverless Gateway project that can be deployed separately.
5+
For more information, please consult the `Serverless Gateway Documentation`_ or the `Serverless Gateway Repository`_.
66

77
Quickstart
88
^^^^^^^^^^
@@ -15,31 +15,36 @@ Quickstart
1515
1616
app = Serverless("example")
1717
18-
app.get("/hello-gateway", memory_limit= 256)
18+
# You can use the get, post, put, and delete decorators
19+
@app.get("/hello-gateway", memory_limit= 256)
1920
def handler(event, context):
2021
return {"body": "Hello from Gateway!"}
2122
22-
* Clone the `Serverless Gateway repository`_
23-
* Follow the steps in README to deploy your API Gateway
24-
* Create an API token for the Gateway. In the gateway repository, you can use a make command:
23+
* Install the `scwgw` helper tool
2524

2625
.. code-block:: console
2726
28-
make generate-token
29-
export TOKEN=$(make get-token)
30-
export GATEWAY_HOST=$(make gateway-host)
27+
pip install scw-gateway
3128
32-
* Finally, use `scw-serverless` to deploy your function and set up the route on your Gateway:
29+
* Deploy your API Gateway
3330

3431
.. code-block:: console
3532
36-
scw-serverless deploy app.py --gateway-url https://${GATEWAY_HOST} --gateway-api-key ${TOKEN}
33+
scwgw infra deploy
34+
35+
* Finally, use `scw-serverless` to deploy your function and set up the route on your gateway:
36+
37+
.. code-block:: console
38+
39+
scw-serverless deploy app.py
3740
3841
* You can now call your function via your Gateway!
3942

4043
.. code-block:: console
4144
42-
$ curl https://${GATEWAY_HOST}/hello-gateway
45+
$ GATEWAY_ENDPOINT=$(scwgw infra endpoint)
46+
$ curl https://${GATEWAY_ENDPOINT}/hello-gateway
4347
> Hello from Gateway!
4448
4549
.. _Serverless Gateway Repository: https://github.com/scaleway/serverless-gateway
50+
.. _Serverless Gateway Documentation: https://serverless-gateway.readthedocs.io/en/latest/

poetry.lock

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "scw-serverless"
3-
version = "1.1.0"
3+
version = "1.2.0"
44
description = "Framework for writing serverless APIs in Python, using Scaleway functions and containers."
55
authors = ["Scaleway Serverless Team <[email protected]>"]
66
readme = "README.md"
@@ -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.3.0"
50+
scw-gateway = "^0.4.0"
5151

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

scw_serverless/gateway/serverless_gateway.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from scw_serverless.config.route import GatewayRoute
77

88
GATEWAY_CLI = "scwgw"
9+
GATEWAY_PYPI = "scw-gateway"
910

1011

1112
class ServerlessGateway:
@@ -18,11 +19,12 @@ def __init__(self) -> None:
1819

1920
if not cli:
2021
click.secho(
21-
"scwgw was not found in $PATH, "
22-
+ "you can install scwgw by running: pip install scwgw",
22+
f"{GATEWAY_CLI} was not found in $PATH, "
23+
+ f"you can install {GATEWAY_CLI} by running:\n"
24+
+ f"pip install {GATEWAY_PYPI}",
2325
fg="red",
2426
)
25-
raise RuntimeError("scwgw is not installed")
27+
raise RuntimeError(f"{GATEWAY_CLI} is not installed")
2628

2729
self.cli = cli
2830

@@ -41,7 +43,7 @@ def add_route(self, route: GatewayRoute) -> None:
4143
if not route.target:
4244
raise RuntimeError(f"route {route.relative_url} is missing upstream target")
4345

44-
cli_args = ["add-route", route.relative_url, route.target]
46+
cli_args = ["route", "add", route.relative_url, route.target]
4547
for method in route.http_methods or []:
4648
cli_args += ["--http-methods", method.value]
4749

tests/integrations/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_deployed_functions_by_name(client: Client, app_instance: Serverless):
6363

6464
def get_gateway_endpoint() -> str:
6565
cmd = subprocess.run(
66-
args=["scwgw", "get-endpoint"],
66+
args=["scwgw", "infra", "endpoint"],
6767
check=True,
6868
capture_output=True,
6969
env=os.environ,

0 commit comments

Comments
 (0)