https://github.com/crossplane/function-template-python
A template for writing a composition function in Python
https://github.com/crossplane/function-template-python
Last synced: 12 months ago
JSON representation
A template for writing a composition function in Python
- Host: GitHub
- URL: https://github.com/crossplane/function-template-python
- Owner: crossplane
- License: apache-2.0
- Created: 2023-11-21T21:48:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-26T07:43:48.000Z (12 months ago)
- Last Synced: 2025-06-26T08:38:46.449Z (12 months ago)
- Language: Python
- Size: 195 KB
- Stars: 16
- Watchers: 6
- Forks: 10
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# function-template-python
[](https://github.com/crossplane/function-template-go/actions/workflows/ci.yml)
A template for writing a [composition function][functions] in [Python][python].
To learn how to use this template:
* [Follow the guide to writing a composition function in Python][function guide]
* [Learn about how composition functions work][functions]
* [Read the function-sdk-python package documentation][package docs]
If you just want to jump in and get started:
1. Replace `function-template-python` with your function's name in
`package/crossplane.yaml`.
1. Add your logic to `RunFunction` in `function/fn.py`
1. Add tests for your logic in `test/test_fn.py`
1. Update this file, `README.md`, to be about your function!
This template uses [Python][python], [Docker][docker], and the [Crossplane
CLI][cli] to build functions.
```shell
# Run the code in development mode, for crossplane beta render
hatch run development
# Lint and format the code - see pyproject.toml
hatch fmt
# Run unit tests - see tests/test_fn.py
hatch test
# Build the function's runtime image - see Dockerfile
$ docker build . --tag=runtime
# Build a function package - see package/crossplane.yaml
$ crossplane xpkg build -f package --embed-runtime-image=runtime
```
[functions]: https://docs.crossplane.io/latest/concepts/composition-functions
[function guide]: https://docs.crossplane.io/knowledge-base/guides/write-a-composition-function-in-python
[package docs]: https://crossplane.github.io/function-sdk-python
[python]: https://python.org
[docker]: https://www.docker.com
[cli]: https://docs.crossplane.io/latest/cli