mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
🔀 Merge branch 'fix-22' into 'main'
✨ — Add a command to generate an auth token (fix #22) Closes #22 See merge request framasoft/framaspace/argos!37
This commit is contained in:
commit
c79054b48b
2 changed files with 37 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
@ -167,5 +168,15 @@ async def migrate():
|
||||||
command.upgrade(alembic_cfg, "head")
|
command.upgrade(alembic_cfg, "head")
|
||||||
|
|
||||||
|
|
||||||
|
@server.command()
|
||||||
|
@coroutine
|
||||||
|
async def generate_token():
|
||||||
|
"""Generate a token, which can be used as an agent’s authentication token.
|
||||||
|
|
||||||
|
It’s actually an UUID
|
||||||
|
"""
|
||||||
|
click.echo(uuid4())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cli()
|
cli()
|
||||||
|
|
31
docs/cli.md
31
docs/cli.md
|
@ -26,14 +26,14 @@ Options:
|
||||||
--help Show this message and exit.
|
--help Show this message and exit.
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
agent Get and run tasks to the provided server.
|
agent Get and run tasks to the provided server.
|
||||||
server
|
server
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--[[[end]]]
|
<!--[[[end]]]
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## Agent commands
|
## Agent command
|
||||||
<!--
|
<!--
|
||||||
.. [[[cog
|
.. [[[cog
|
||||||
help(["agent", "--help"])
|
help(["agent", "--help"])
|
||||||
|
@ -77,9 +77,10 @@ Options:
|
||||||
--help Show this message and exit.
|
--help Show this message and exit.
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
cleandb Clean the database (to run routinely)
|
cleandb Clean the database (to run routinely)
|
||||||
migrate Run database migrations
|
generate-token Generate a token, which can be used as an agent’s...
|
||||||
reload-config Read tasks config and add/delete tasks in database if...
|
migrate Run database migrations
|
||||||
|
reload-config Read tasks config and add/delete tasks in database if...
|
||||||
start Starts the server
|
start Starts the server
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -172,3 +173,23 @@ Options:
|
||||||
<!--[[[end]]]
|
<!--[[[end]]]
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
### Server generate-token command
|
||||||
|
|
||||||
|
<!--
|
||||||
|
.. [[[cog
|
||||||
|
help(["server", "generate-token", "--help"])
|
||||||
|
.. ]]] -->
|
||||||
|
|
||||||
|
```man
|
||||||
|
Usage: argos server generate-token [OPTIONS]
|
||||||
|
|
||||||
|
Generate a token, which can be used as an agent’s authentication token.
|
||||||
|
|
||||||
|
It’s actually an UUID
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--help Show this message and exit.
|
||||||
|
```
|
||||||
|
|
||||||
|
<!--[[[end]]]
|
||||||
|
-->
|
||||||
|
|
Loading…
Reference in a new issue