[cli/domain] now instantiate HalfAPI and manually add the domain before calling schema function

This commit is contained in:
Maxime Alves LIRMM 2021-12-13 12:45:52 +01:00
parent f82cd5552b
commit e9bf94a607
3 changed files with 15 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3
__version__ = '0.6.2'
__version__ = '0.6.1'
def version():
return f'HalfAPI version:{__version__}'

View File

@ -146,9 +146,17 @@ def domain(domain, delete, update, create, read): #, domains, read, create, upd
if delete:
raise NotImplementedError
if read:
half_domain = HalfDomain(
domain,
config=CONFIG.get('domain').get('domain_name', {}))
from ..conf import CONFIG
from ..halfapi import HalfAPI
try:
config_domain = CONFIG.pop('domain').get(domain, {})
except KeyError:
config_domain = {}
halfapi = HalfAPI(CONFIG)
half_domain = halfapi.add_domain(domain, config=config_domain)
click.echo(orjson.dumps(
half_domain.schema(),

View File

@ -53,8 +53,10 @@ def run(host, port, reload, secret, production, loglevel, prefix, check, dryrun,
if domain:
# If we specify a domain to run as argument
if 'domain' not in CONFIG:
CONFIG['domain'] = {}
for key in CONFIG['domain']:
for key in CONFIG.get('domain'):
# Disable all domains
CONFIG['domain'].pop(key)