-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fastapi-framework init profile and extension (#1868)
This PR implements the spec ISD160 - 12-Factor FastAPI Support" for charmcraft. For that, a new init profile called "fastapi-framework" and a new fastapi extension, called "fastapi-framework" are needed. These additions are similar to the flask and django init profiles and extensions. For the fastapi profile, the base 24.04 is used. --------- Co-authored-by: Alex Lowe <alex.lowe@canonical.com>
- Loading branch information
1 parent
34b9b3d
commit ec881a4
Showing
9 changed files
with
243 additions
and
5 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
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,9 @@ | ||
venv/ | ||
build/ | ||
*.charm | ||
.tox/ | ||
.coverage | ||
__pycache__/ | ||
*.py[cod] | ||
.idea | ||
.vscode/ |
59 changes: 59 additions & 0 deletions
59
charmcraft/templates/init-fastapi-framework/charmcraft.yaml.j2
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,59 @@ | ||
# This file configures Charmcraft. | ||
# See https://juju.is/docs/sdk/charmcraft-config for guidance. | ||
|
||
name: {{ name }} | ||
|
||
type: charm | ||
|
||
base: ubuntu@24.04 | ||
|
||
# the platforms this charm should be built on and run on. | ||
# you can check your architecture with `dpkg --print-architecture` | ||
platforms: | ||
amd64: | ||
# arm64: | ||
# ppc64el: | ||
# s390x: | ||
|
||
# (Required) | ||
summary: A very short one-line summary of the FastAPI application. | ||
|
||
# (Required) | ||
description: | | ||
A comprehensive overview of your FastAPI application. | ||
|
||
extensions: | ||
- fastapi-framework | ||
|
||
# Uncomment the integrations used by your application | ||
# Integrations set to "optional: false" will block the charm | ||
# until the applications are integrated. | ||
# requires: | ||
# mysql: | ||
# interface: mysql_client | ||
# optional: false | ||
# limit: 1 | ||
# postgresql: | ||
# interface: postgresql_client | ||
# optional: false | ||
# limit: 1 | ||
# mongodb: | ||
# interface: mongodb_client | ||
# optional: false | ||
# limit: 1 | ||
# redis: | ||
# interface: redis | ||
# optional: false | ||
# limit: 1 | ||
# s3: | ||
# interface: s3 | ||
# optional: false | ||
# limit: 1 | ||
# saml: | ||
# interface: saml | ||
# optional: false | ||
# limit: 1 | ||
# rabbitmq: | ||
# interface: rabbitmq | ||
# optional: false | ||
# limit: 1 |
1 change: 1 addition & 0 deletions
1
charmcraft/templates/init-fastapi-framework/requirements.txt.j2
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 @@ | ||
paas-app-charmer==1.* |
30 changes: 30 additions & 0 deletions
30
charmcraft/templates/init-fastapi-framework/src/charm.py.j2
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,30 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright {{ year }} {{ author }} | ||
# See LICENSE file for licensing details. | ||
|
||
"""FastAPI Charm entrypoint.""" | ||
|
||
import logging | ||
import typing | ||
|
||
import ops | ||
|
||
import paas_app_charmer.fastapi | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class {{ class_name }}(paas_app_charmer.fastapi.Charm): | ||
"""FastAPI Charm service.""" | ||
|
||
def __init__(self, *args: typing.Any) -> None: | ||
"""Initialize the instance. | ||
Args: | ||
args: passthrough to CharmBase. | ||
""" | ||
super().__init__(*args) | ||
|
||
|
||
if __name__ == "__main__": | ||
ops.main.main({{ class_name }}) |
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