[enh] Several fixes in domain config

This commit is contained in:
ljf 2021-09-04 19:05:13 +02:00
parent 97c0a74f8f
commit fd5b2e8953
4 changed files with 135 additions and 129 deletions

View file

@ -575,7 +575,7 @@ domain:
action_help: Apply a new configuration action_help: Apply a new configuration
api: PUT /domains/<domain>/config api: PUT /domains/<domain>/config
arguments: arguments:
app: domain:
help: Domain name help: Domain name
key: key:
help: The question or form key help: The question or form key

View file

@ -3,13 +3,14 @@ i18n = "domain_config"
[feature] [feature]
[feature.mail] [feature.mail]
services = ['postfix', 'dovecot']
[feature.mail.mail_out] [feature.mail.mail_out]
type = "boolean" type = "boolean"
default = true default = 1
[feature.mail.mail_in] [feature.mail.mail_in]
type = "boolean" type = "boolean"
default = true default = 1
[feature.mail.backup_mx] [feature.mail.backup_mx]
type = "tags" type = "tags"
@ -21,10 +22,11 @@ i18n = "domain_config"
[feature.xmpp.xmpp] [feature.xmpp.xmpp]
type = "boolean" type = "boolean"
default = false default = 0
[dns] [dns]
[dns.registrar] [dns.registrar]
optional = true
[dns.registrar.unsupported] [dns.registrar.unsupported]
ask = "DNS zone of this domain can't be auto-configured, you should do it manually." ask = "DNS zone of this domain can't be auto-configured, you should do it manually."
type = "alert" type = "alert"

View file

@ -1,7 +1,7 @@
[aliyun] [aliyun]
[aliyun.auth_key_id] [aliyun.auth_key_id]
type = "string" type = "string"
redact = True redact = true
[aliyun.auth_secret] [aliyun.auth_secret]
type = "password" type = "password"
@ -9,7 +9,7 @@
[aurora] [aurora]
[aurora.auth_api_key] [aurora.auth_api_key]
type = "string" type = "string"
redact = True redact = true
[aurora.auth_secret_key] [aurora.auth_secret_key]
type = "password" type = "password"
@ -17,48 +17,48 @@
[azure] [azure]
[azure.auth_client_id] [azure.auth_client_id]
type = "string" type = "string"
redact = True redact = true
[azure.auth_client_secret] [azure.auth_client_secret]
type = "password" type = "password"
[azure.auth_tenant_id] [azure.auth_tenant_id]
type = "string" type = "string"
redact = True redact = true
[azure.auth_subscription_id] [azure.auth_subscription_id]
type = "string" type = "string"
redact = True redact = true
[azure.resource_group] [azure.resource_group]
type = "string" type = "string"
redact = True redact = true
[cloudflare] [cloudflare]
[cloudflare.auth_username] [cloudflare.auth_username]
type = "string" type = "string"
redact = True redact = true
[cloudflare.auth_token] [cloudflare.auth_token]
type = "string" type = "string"
redact = True redact = true
[cloudflare.zone_id] [cloudflare.zone_id]
type = "string" type = "string"
redact = True redact = true
[cloudns] [cloudns]
[cloudns.auth_id] [cloudns.auth_id]
type = "string" type = "string"
redact = True redact = true
[cloudns.auth_subid] [cloudns.auth_subid]
type = "string" type = "string"
redact = True redact = true
[cloudns.auth_subuser] [cloudns.auth_subuser]
type = "string" type = "string"
redact = True redact = true
[cloudns.auth_password] [cloudns.auth_password]
type = "password" type = "password"
@ -71,50 +71,50 @@
[cloudxns] [cloudxns]
[cloudxns.auth_username] [cloudxns.auth_username]
type = "string" type = "string"
redact = True redact = true
[cloudxns.auth_token] [cloudxns.auth_token]
type = "string" type = "string"
redact = True redact = true
[conoha] [conoha]
[conoha.auth_region] [conoha.auth_region]
type = "string" type = "string"
redact = True redact = true
[conoha.auth_token] [conoha.auth_token]
type = "string" type = "string"
redact = True redact = true
[conoha.auth_username] [conoha.auth_username]
type = "string" type = "string"
redact = True redact = true
[conoha.auth_password] [conoha.auth_password]
type = "password" type = "password"
[conoha.auth_tenant_id] [conoha.auth_tenant_id]
type = "string" type = "string"
redact = True redact = true
[constellix] [constellix]
[constellix.auth_username] [constellix.auth_username]
type = "string" type = "string"
redact = True redact = true
[constellix.auth_token] [constellix.auth_token]
type = "string" type = "string"
redact = True redact = true
[digitalocean] [digitalocean]
[digitalocean.auth_token] [digitalocean.auth_token]
type = "string" type = "string"
redact = True redact = true
[dinahosting] [dinahosting]
[dinahosting.auth_username] [dinahosting.auth_username]
type = "string" type = "string"
redact = True redact = true
[dinahosting.auth_password] [dinahosting.auth_password]
type = "password" type = "password"
@ -125,78 +125,78 @@
[directadmin.auth_username] [directadmin.auth_username]
type = "string" type = "string"
redact = True redact = true
[directadmin.endpoint] [directadmin.endpoint]
type = "string" type = "string"
redact = True redact = true
[dnsimple] [dnsimple]
[dnsimple.auth_token] [dnsimple.auth_token]
type = "string" type = "string"
redact = True redact = true
[dnsimple.auth_username] [dnsimple.auth_username]
type = "string" type = "string"
redact = True redact = true
[dnsimple.auth_password] [dnsimple.auth_password]
type = "password" type = "password"
[dnsimple.auth_2fa] [dnsimple.auth_2fa]
type = "string" type = "string"
redact = True redact = true
[dnsmadeeasy] [dnsmadeeasy]
[dnsmadeeasy.auth_username] [dnsmadeeasy.auth_username]
type = "string" type = "string"
redact = True redact = true
[dnsmadeeasy.auth_token] [dnsmadeeasy.auth_token]
type = "string" type = "string"
redact = True redact = true
[dnspark] [dnspark]
[dnspark.auth_username] [dnspark.auth_username]
type = "string" type = "string"
redact = True redact = true
[dnspark.auth_token] [dnspark.auth_token]
type = "string" type = "string"
redact = True redact = true
[dnspod] [dnspod]
[dnspod.auth_username] [dnspod.auth_username]
type = "string" type = "string"
redact = True redact = true
[dnspod.auth_token] [dnspod.auth_token]
type = "string" type = "string"
redact = True redact = true
[dreamhost] [dreamhost]
[dreamhost.auth_token] [dreamhost.auth_token]
type = "string" type = "string"
redact = True redact = true
[dynu] [dynu]
[dynu.auth_token] [dynu.auth_token]
type = "string" type = "string"
redact = True redact = true
[easydns] [easydns]
[easydns.auth_username] [easydns.auth_username]
type = "string" type = "string"
redact = True redact = true
[easydns.auth_token] [easydns.auth_token]
type = "string" type = "string"
redact = True redact = true
[easyname] [easyname]
[easyname.auth_username] [easyname.auth_username]
type = "string" type = "string"
redact = True redact = true
[easyname.auth_password] [easyname.auth_password]
type = "password" type = "password"
@ -204,7 +204,7 @@
[euserv] [euserv]
[euserv.auth_username] [euserv.auth_username]
type = "string" type = "string"
redact = True redact = true
[euserv.auth_password] [euserv.auth_password]
type = "password" type = "password"
@ -212,7 +212,7 @@
[exoscale] [exoscale]
[exoscale.auth_key] [exoscale.auth_key]
type = "string" type = "string"
redact = True redact = true
[exoscale.auth_secret] [exoscale.auth_secret]
type = "password" type = "password"
@ -220,7 +220,7 @@
[gandi] [gandi]
[gandi.auth_token] [gandi.auth_token]
type = "string" type = "string"
redact = True redact = true
[gandi.api_protocol] [gandi.api_protocol]
type = "string" type = "string"
@ -230,7 +230,7 @@
[gehirn] [gehirn]
[gehirn.auth_token] [gehirn.auth_token]
type = "string" type = "string"
redact = True redact = true
[gehirn.auth_secret] [gehirn.auth_secret]
type = "password" type = "password"
@ -238,16 +238,16 @@
[glesys] [glesys]
[glesys.auth_username] [glesys.auth_username]
type = "string" type = "string"
redact = True redact = true
[glesys.auth_token] [glesys.auth_token]
type = "string" type = "string"
redact = True redact = true
[godaddy] [godaddy]
[godaddy.auth_key] [godaddy.auth_key]
type = "string" type = "string"
redact = True redact = true
[godaddy.auth_secret] [godaddy.auth_secret]
type = "password" type = "password"
@ -255,12 +255,12 @@
[googleclouddns] [googleclouddns]
[goggleclouddns.auth_service_account_info] [goggleclouddns.auth_service_account_info]
type = "string" type = "string"
redact = True redact = true
[gransy] [gransy]
[gransy.auth_username] [gransy.auth_username]
type = "string" type = "string"
redact = True redact = true
[gransy.auth_password] [gransy.auth_password]
type = "password" type = "password"
@ -268,7 +268,7 @@
[gratisdns] [gratisdns]
[gratisdns.auth_username] [gratisdns.auth_username]
type = "string" type = "string"
redact = True redact = true
[gratisdns.auth_password] [gratisdns.auth_password]
type = "password" type = "password"
@ -276,7 +276,7 @@
[henet] [henet]
[henet.auth_username] [henet.auth_username]
type = "string" type = "string"
redact = True redact = true
[henet.auth_password] [henet.auth_password]
type = "password" type = "password"
@ -284,17 +284,17 @@
[hetzner] [hetzner]
[hetzner.auth_token] [hetzner.auth_token]
type = "string" type = "string"
redact = True redact = true
[hostingde] [hostingde]
[hostingde.auth_token] [hostingde.auth_token]
type = "string" type = "string"
redact = True redact = true
[hover] [hover]
[hover.auth_username] [hover.auth_username]
type = "string" type = "string"
redact = True redact = true
[hover.auth_password] [hover.auth_password]
type = "password" type = "password"
@ -302,37 +302,37 @@
[infoblox] [infoblox]
[infoblox.auth_user] [infoblox.auth_user]
type = "string" type = "string"
redact = True redact = true
[infoblox.auth_psw] [infoblox.auth_psw]
type = "password" type = "password"
[infoblox.ib_view] [infoblox.ib_view]
type = "string" type = "string"
redact = True redact = true
[infoblox.ib_host] [infoblox.ib_host]
type = "string" type = "string"
redact = True redact = true
[infomaniak] [infomaniak]
[infomaniak.auth_token] [infomaniak.auth_token]
type = "string" type = "string"
redact = True redact = true
[internetbs] [internetbs]
[internetbs.auth_key] [internetbs.auth_key]
type = "string" type = "string"
redact = True redact = true
[internetbs.auth_password] [internetbs.auth_password]
type = "string" type = "string"
redact = True redact = true
[inwx] [inwx]
[inwx.auth_username] [inwx.auth_username]
type = "string" type = "string"
redact = True redact = true
[inwx.auth_password] [inwx.auth_password]
type = "password" type = "password"
@ -340,79 +340,79 @@
[joker] [joker]
[joker.auth_token] [joker.auth_token]
type = "string" type = "string"
redact = True redact = true
[linode] [linode]
[linode.auth_token] [linode.auth_token]
type = "string" type = "string"
redact = True redact = true
[linode4] [linode4]
[linode4.auth_token] [linode4.auth_token]
type = "string" type = "string"
redact = True redact = true
[localzone] [localzone]
[localzone.filename] [localzone.filename]
type = "string" type = "string"
redact = True redact = true
[luadns] [luadns]
[luadns.auth_username] [luadns.auth_username]
type = "string" type = "string"
redact = True redact = true
[luadns.auth_token] [luadns.auth_token]
type = "string" type = "string"
redact = True redact = true
[memset] [memset]
[memset.auth_token] [memset.auth_token]
type = "string" type = "string"
redact = True redact = true
[mythicbeasts] [mythicbeasts]
[mythicbeasts.auth_username] [mythicbeasts.auth_username]
type = "string" type = "string"
redact = True redact = true
[mythicbeasts.auth_password] [mythicbeasts.auth_password]
type = "password" type = "password"
[mythicbeasts.auth_token] [mythicbeasts.auth_token]
type = "string" type = "string"
redact = True redact = true
[namecheap] [namecheap]
[namecheap.auth_token] [namecheap.auth_token]
type = "string" type = "string"
redact = True redact = true
[namecheap.auth_username] [namecheap.auth_username]
type = "string" type = "string"
redact = True redact = true
[namecheap.auth_client_ip] [namecheap.auth_client_ip]
type = "string" type = "string"
redact = True redact = true
[namecheap.auth_sandbox] [namecheap.auth_sandbox]
type = "string" type = "string"
redact = True redact = true
[namesilo] [namesilo]
[namesilo.auth_token] [namesilo.auth_token]
type = "string" type = "string"
redact = True redact = true
[netcup] [netcup]
[netcup.auth_customer_id] [netcup.auth_customer_id]
type = "string" type = "string"
redact = True redact = true
[netcup.auth_api_key] [netcup.auth_api_key]
type = "string" type = "string"
redact = True redact = true
[netcup.auth_api_password] [netcup.auth_api_password]
type = "password" type = "password"
@ -420,89 +420,89 @@
[nfsn] [nfsn]
[nfsn.auth_username] [nfsn.auth_username]
type = "string" type = "string"
redact = True redact = true
[nfsn.auth_token] [nfsn.auth_token]
type = "string" type = "string"
redact = True redact = true
[njalla] [njalla]
[njalla.auth_token] [njalla.auth_token]
type = "string" type = "string"
redact = True redact = true
[nsone] [nsone]
[nsone.auth_token] [nsone.auth_token]
type = "string" type = "string"
redact = True redact = true
[onapp] [onapp]
[onapp.auth_username] [onapp.auth_username]
type = "string" type = "string"
redact = True redact = true
[onapp.auth_token] [onapp.auth_token]
type = "string" type = "string"
redact = True redact = true
[onapp.auth_server] [onapp.auth_server]
type = "string" type = "string"
redact = True redact = true
[online] [online]
[online.auth_token] [online.auth_token]
type = "string" type = "string"
redact = True redact = true
[ovh] [ovh]
[ovh.auth_entrypoint] [ovh.auth_entrypoint]
type = "string" type = "string"
redact = True redact = true
[ovh.auth_application_key] [ovh.auth_application_key]
type = "string" type = "string"
redact = True redact = true
[ovh.auth_application_secret] [ovh.auth_application_secret]
type = "password" type = "password"
[ovh.auth_consumer_key] [ovh.auth_consumer_key]
type = "string" type = "string"
redact = True redact = true
[plesk] [plesk]
[plesk.auth_username] [plesk.auth_username]
type = "string" type = "string"
redact = True redact = true
[plesk.auth_password] [plesk.auth_password]
type = "password" type = "password"
[plesk.plesk_server] [plesk.plesk_server]
type = "string" type = "string"
redact = True redact = true
[pointhq] [pointhq]
[pointhq.auth_username] [pointhq.auth_username]
type = "string" type = "string"
redact = True redact = true
[pointhq.auth_token] [pointhq.auth_token]
type = "string" type = "string"
redact = True redact = true
[powerdns] [powerdns]
[powerdns.auth_token] [powerdns.auth_token]
type = "string" type = "string"
redact = True redact = true
[powerdns.pdns_server] [powerdns.pdns_server]
type = "string" type = "string"
redact = True redact = true
[powerdns.pdns_server_id] [powerdns.pdns_server_id]
type = "string" type = "string"
redact = True redact = true
[powerdns.pdns_disable_notify] [powerdns.pdns_disable_notify]
type = "boolean" type = "boolean"
@ -510,67 +510,67 @@
[rackspace] [rackspace]
[rackspace.auth_account] [rackspace.auth_account]
type = "string" type = "string"
redact = True redact = true
[rackspace.auth_username] [rackspace.auth_username]
type = "string" type = "string"
redact = True redact = true
[rackspace.auth_api_key] [rackspace.auth_api_key]
type = "string" type = "string"
redact = True redact = true
[rackspace.auth_token] [rackspace.auth_token]
type = "string" type = "string"
redact = True redact = true
[rackspace.sleep_time] [rackspace.sleep_time]
type = "string" type = "string"
redact = True redact = true
[rage4] [rage4]
[rage4.auth_username] [rage4.auth_username]
type = "string" type = "string"
redact = True redact = true
[rage4.auth_token] [rage4.auth_token]
type = "string" type = "string"
redact = True redact = true
[rcodezero] [rcodezero]
[rcodezero.auth_token] [rcodezero.auth_token]
type = "string" type = "string"
redact = True redact = true
[route53] [route53]
[route53.auth_access_key] [route53.auth_access_key]
type = "string" type = "string"
redact = True redact = true
[route53.auth_access_secret] [route53.auth_access_secret]
type = "password" type = "password"
[route53.private_zone] [route53.private_zone]
type = "string" type = "string"
redact = True redact = true
[route53.auth_username] [route53.auth_username]
type = "string" type = "string"
redact = True redact = true
[route53.auth_token] [route53.auth_token]
type = "string" type = "string"
redact = True redact = true
[safedns] [safedns]
[safedns.auth_token] [safedns.auth_token]
type = "string" type = "string"
redact = True redact = true
[sakuracloud] [sakuracloud]
[sakuracloud.auth_token] [sakuracloud.auth_token]
type = "string" type = "string"
redact = True redact = true
[sakuracloud.auth_secret] [sakuracloud.auth_secret]
type = "password" type = "password"
@ -578,29 +578,29 @@
[softlayer] [softlayer]
[softlayer.auth_username] [softlayer.auth_username]
type = "string" type = "string"
redact = True redact = true
[softlayer.auth_api_key] [softlayer.auth_api_key]
type = "string" type = "string"
redact = True redact = true
[transip] [transip]
[transip.auth_username] [transip.auth_username]
type = "string" type = "string"
redact = True redact = true
[transip.auth_api_key] [transip.auth_api_key]
type = "string" type = "string"
redact = True redact = true
[ultradns] [ultradns]
[ultradns.auth_token] [ultradns.auth_token]
type = "string" type = "string"
redact = True redact = true
[ultradns.auth_username] [ultradns.auth_username]
type = "string" type = "string"
redact = True redact = true
[ultradns.auth_password] [ultradns.auth_password]
type = "password" type = "password"
@ -608,29 +608,29 @@
[vultr] [vultr]
[vultr.auth_token] [vultr.auth_token]
type = "string" type = "string"
redact = True redact = true
[yandex] [yandex]
[yandex.auth_token] [yandex.auth_token]
type = "string" type = "string"
redact = True redact = true
[zeit] [zeit]
[zeit.auth_token] [zeit.auth_token]
type = "string" type = "string"
redact = True redact = true
[zilore] [zilore]
[zilore.auth_key] [zilore.auth_key]
type = "string" type = "string"
redact = True redact = true
[zonomi] [zonomi]
[zonomy.auth_token] [zonomy.auth_token]
type = "string" type = "string"
redact = True redact = true
[zonomy.auth_entrypoint] [zonomy.auth_entrypoint]
type = "string" type = "string"
redact = True redact = true

View file

@ -28,7 +28,9 @@ import os
from moulinette import m18n, Moulinette from moulinette import m18n, Moulinette
from moulinette.core import MoulinetteError from moulinette.core import MoulinetteError
from moulinette.utils.log import getActionLogger from moulinette.utils.log import getActionLogger
from moulinette.utils.filesystem import mkdir, write_to_file, read_yaml, write_to_yaml from moulinette.utils.filesystem import (
mkdir, write_to_file, read_yaml, write_to_yaml, read_toml
)
from yunohost.settings import is_boolean from yunohost.settings import is_boolean
from yunohost.app import ( from yunohost.app import (
@ -37,8 +39,10 @@ from yunohost.app import (
_get_app_settings, _get_app_settings,
_get_conflicting_apps, _get_conflicting_apps,
) )
from yunohost.regenconf import regen_conf, _force_clear_hashes, _process_regen_conf from yunohost.regenconf import (
from yunohost.utils.config import ConfigPanel regen_conf, _force_clear_hashes, _process_regen_conf
)
from yunohost.utils.config import ConfigPanel, Question
from yunohost.utils.error import YunohostError, YunohostValidationError from yunohost.utils.error import YunohostError, YunohostValidationError
from yunohost.log import is_unit_operation from yunohost.log import is_unit_operation
from yunohost.hook import hook_callback from yunohost.hook import hook_callback
@ -407,11 +411,11 @@ def domain_config_get(domain, key='', mode='classic'):
return config.get(key, mode) return config.get(key, mode)
@is_unit_operation() @is_unit_operation()
def domain_config_set(operation_logger, app, key=None, value=None, args=None, args_file=None): def domain_config_set(operation_logger, domain, key=None, value=None, args=None, args_file=None):
""" """
Apply a new domain configuration Apply a new domain configuration
""" """
Question.operation_logger = operation_logger
config = DomainConfigPanel(domain) config = DomainConfigPanel(domain)
return config.set(key, value, args, args_file) return config.set(key, value, args, args_file)
@ -432,7 +436,7 @@ class DomainConfigPanel(ConfigPanel):
self.dns_zone = get_dns_zone_from_domain(self.domain) self.dns_zone = get_dns_zone_from_domain(self.domain)
try: try:
registrar = _relevant_provider_for_domain(self.dns_zone) registrar = _relevant_provider_for_domain(self.dns_zone)[0]
except ValueError: except ValueError:
return toml return toml