49 lines
1.1 KiB
Markdown
49 lines
1.1 KiB
Markdown
|
|
---
|
||
|
|
name: update-docstring
|
||
|
|
description: View or update the Fission configuration embedded in a Python function's docstring
|
||
|
|
---
|
||
|
|
|
||
|
|
View or update Fission configuration in a Python function docstring using the update-docstring script.
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# View current config
|
||
|
|
./fission-python/update-docstring.sh <file.py> <function-name> --get
|
||
|
|
|
||
|
|
# Update config
|
||
|
|
./fission-python/update-docstring.sh <file.py> <function-name> --set '<json>'
|
||
|
|
```
|
||
|
|
|
||
|
|
## Docstring format
|
||
|
|
|
||
|
|
The script reads/writes Fission config between ` ```fission ` and ` ``` ` markers:
|
||
|
|
|
||
|
|
```python
|
||
|
|
def main():
|
||
|
|
"""
|
||
|
|
```fission
|
||
|
|
{
|
||
|
|
"name": "function-name",
|
||
|
|
"http_triggers": {
|
||
|
|
"trigger-name": {"url": "/endpoint", "methods": ["GET"]}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
"""
|
||
|
|
```
|
||
|
|
|
||
|
|
## Examples
|
||
|
|
|
||
|
|
User asks: "Show the Fission config of function `main` in `./my-api/src/func.py`"
|
||
|
|
|
||
|
|
```bash
|
||
|
|
./fission-python/update-docstring.sh ./my-api/src/func.py main --get
|
||
|
|
```
|
||
|
|
|
||
|
|
User asks: "Update the HTTP trigger URL to `/v2/items`"
|
||
|
|
|
||
|
|
```bash
|
||
|
|
./fission-python/update-docstring.sh ./my-api/src/func.py main --set '{"http_triggers": {"api": {"url": "/v2/items", "methods": ["GET"]}}}'
|
||
|
|
```
|