-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce templates/ directory and add basic template (#78)
Co-authored-by: Luca Pivetta <36865043+Pive01@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
147 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Extension Template | ||
================== | ||
|
||
This is a [cookiecutter](https://github.com/cookiecutter/cookiecutter) template that is used when you invoke. | ||
|
||
```console | ||
localstack extensions dev new | ||
``` | ||
|
||
It contains a simple python distribution config, and some boilerplate extension code. |
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,11 @@ | ||
{ | ||
"project_name": "My LocalStack Extension", | ||
"project_short_description": "All the boilerplate you need to create a LocalStack extension.", | ||
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}", | ||
"module_name": "{{ cookiecutter.project_slug.replace('-', '_') }}", | ||
"class_name": "{{ cookiecutter.project_name.replace('-', ' ').replace('_', ' ').title().replace(' ', '') }}", | ||
"full_name": "Jane Doe", | ||
"email": "jane@example.com", | ||
"github_username": "janedoe", | ||
"version": "0.1.0" | ||
} |
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,5 @@ | ||
.venv | ||
dist | ||
build | ||
**/*.egg-info | ||
.eggs |
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,32 @@ | ||
VENV_BIN = python3 -m venv | ||
VENV_DIR ?= .venv | ||
VENV_ACTIVATE = $(VENV_DIR)/bin/activate | ||
VENV_RUN = . $(VENV_ACTIVATE) | ||
|
||
venv: $(VENV_ACTIVATE) | ||
|
||
$(VENV_ACTIVATE): pyproject.toml | ||
test -d .venv || $(VENV_BIN) .venv | ||
$(VENV_RUN); pip install --upgrade pip setuptools plux | ||
$(VENV_RUN); pip install -e .[dev] | ||
touch $(VENV_DIR)/bin/activate | ||
|
||
clean: | ||
rm -rf .venv/ | ||
rm -rf build/ | ||
rm -rf .eggs/ | ||
rm -rf *.egg-info/ | ||
|
||
install: venv | ||
$(VENV_RUN); python -m plux entrypoints | ||
|
||
dist: venv | ||
$(VENV_RUN); python -m build | ||
|
||
publish: clean-dist venv dist | ||
$(VENV_RUN); pip install --upgrade twine; twine upload dist/* | ||
|
||
clean-dist: clean | ||
rm -rf dist/ | ||
|
||
.PHONY: clean clean-dist dist install publish |
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,34 @@ | ||
{{ cookiecutter.project_name }} | ||
=============================== | ||
|
||
{{ cookiecutter.project_short_description }} | ||
|
||
## Install local development version | ||
|
||
To install the extension into localstack in developer mode, you will need Python 3.10, and create a virtual environment in the extensions project. | ||
|
||
In the newly generated project, simply run | ||
|
||
```bash | ||
make install | ||
``` | ||
|
||
Then, to enable the extension for LocalStack, run | ||
|
||
```bash | ||
localstack extensions dev enable . | ||
``` | ||
|
||
You can then start LocalStack with `EXTENSION_DEV_MODE=1` to load all enabled extensions: | ||
|
||
```bash | ||
EXTENSION_DEV_MODE=1 localstack start | ||
``` | ||
|
||
## Install from GitHub repository | ||
|
||
To distribute your extension, simply upload it to your github account. Your extension can then be installed via: | ||
|
||
```bash | ||
localstack extensions install "git+https://github.com/{{cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/#egg={{ cookiecutter.project_slug }}" | ||
``` |
29 changes: 29 additions & 0 deletions
29
templates/basic/{{cookiecutter.project_slug}}/pyproject.toml
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,29 @@ | ||
[build-system] | ||
requires = ["setuptools", 'wheel', 'plux>=1.3.1'] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "{{ cookiecutter.project_slug }}" | ||
version = "{{ cookiecutter.version }}" | ||
description = "LocalStack Extension: {{ cookiecutter.project_name }}" | ||
readme = {file = "README.md", content-type = "text/markdown; charset=UTF-8"} | ||
requires-python = ">=3.8" | ||
license = {text = "UNLICENSED"} | ||
authors = [ | ||
{ name = "{{ cookiecutter.full_name }}", email = "{{ cookiecutter.email }}" } | ||
] | ||
keywords = ["localstack", "localstack-extension", "extension"] | ||
classifiers = [] | ||
dependencies = [ | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}" | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"localstack>=0.0.0.dev" | ||
] | ||
|
||
[project.entry-points."localstack.extensions"] | ||
{{ cookiecutter.module_name }} = "{{ cookiecutter.module_name }}.extension:{{ cookiecutter.class_name }}" |
1 change: 1 addition & 0 deletions
1
templates/basic/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/__init__.py
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 @@ | ||
name = "{{ cookiecutter.module_name }}" |
22 changes: 22 additions & 0 deletions
22
templates/basic/{{cookiecutter.project_slug}}/{{cookiecutter.module_name}}/extension.py
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,22 @@ | ||
from localstack.extensions.api import Extension, http, aws | ||
|
||
class {{ cookiecutter.class_name }}(Extension): | ||
name = "{{ cookiecutter.project_slug }}" | ||
|
||
def on_extension_load(self): | ||
print("MyExtension: extension is loaded") | ||
|
||
def on_platform_start(self): | ||
print("MyExtension: localstack is starting") | ||
|
||
def on_platform_ready(self): | ||
print("MyExtension: localstack is running") | ||
|
||
def update_gateway_routes(self, router: http.Router[http.RouteHandler]): | ||
pass | ||
|
||
def update_request_handlers(self, handlers: aws.CompositeHandler): | ||
pass | ||
|
||
def update_response_handlers(self, handlers: aws.CompositeResponseHandler): | ||
pass |