mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 09:52:38 +02:00
🔀 Merge branch 'feature/validate-config-access' into 'main'
☝🧐 — Validate config file readability
See merge request framasoft/framaspace/argos!48
This commit is contained in:
commit
6f405f0912
2 changed files with 15 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
## [Unreleased]
|
||||
|
||||
- 🐛 — Fix --config option for some commands
|
||||
- ☝️🧐 — Validate config file readability
|
||||
|
||||
## 0.1.0
|
||||
|
||||
|
|
|
@ -31,6 +31,16 @@ def coroutine(f):
|
|||
return wrapper
|
||||
|
||||
|
||||
def validate_config_access(ctx, param, value):
|
||||
if os.path.isfile(value) and os.access(value, os.R_OK):
|
||||
return value
|
||||
|
||||
if os.path.isfile(value):
|
||||
raise click.BadParameter(f"the file {value} is not readabale.")
|
||||
|
||||
raise click.BadParameter(f"the file {value} does not exists or is not reachable.")
|
||||
|
||||
|
||||
@click.group()
|
||||
def cli():
|
||||
pass
|
||||
|
@ -93,6 +103,7 @@ def agent(server_url, auth, max_tasks, wait_time, log_level):
|
|||
help="Path of the configuration file. "
|
||||
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead.",
|
||||
envvar="ARGOS_YAML_FILE",
|
||||
callback=validate_config_access,
|
||||
)
|
||||
@click.option("--reload", is_flag=True, help="Enable hot reloading")
|
||||
def start(host, port, config, reload):
|
||||
|
@ -140,6 +151,7 @@ def validate_max_results(ctx, param, value):
|
|||
help="Path of the configuration file. "
|
||||
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead.",
|
||||
envvar="ARGOS_YAML_FILE",
|
||||
callback=validate_config_access,
|
||||
)
|
||||
@coroutine
|
||||
async def cleandb(max_results, max_lock_seconds, config):
|
||||
|
@ -170,6 +182,7 @@ async def cleandb(max_results, max_lock_seconds, config):
|
|||
help="Path of the configuration file. "
|
||||
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead.",
|
||||
envvar="ARGOS_YAML_FILE",
|
||||
callback=validate_config_access,
|
||||
)
|
||||
@coroutine
|
||||
async def reload_config(config):
|
||||
|
@ -200,6 +213,7 @@ async def reload_config(config):
|
|||
help="Path of the configuration file. "
|
||||
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead.",
|
||||
envvar="ARGOS_YAML_FILE",
|
||||
callback=validate_config_access,
|
||||
)
|
||||
@coroutine
|
||||
async def migrate(config):
|
||||
|
|
Loading…
Reference in a new issue