Add DNS to add-on (#1204)

This commit is contained in:
Pascal Vizeli 2019-08-14 09:53:03 +02:00 committed by GitHub
parent 138bb12f98
commit b77c42384d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

1
API.md
View File

@ -474,6 +474,7 @@ Get all available addons.
"name": "xy bla", "name": "xy bla",
"slug": "xdssd_xybla", "slug": "xdssd_xybla",
"hostname": "xdssd-xybla", "hostname": "xdssd-xybla",
"dns": [],
"description": "description", "description": "description",
"long_description": "null|markdown", "long_description": "null|markdown",
"auto_update": "bool", "auto_update": "bool",

View File

@ -9,7 +9,7 @@ import secrets
import shutil import shutil
import tarfile import tarfile
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
from typing import Any, Awaitable, Dict, Optional from typing import Any, Awaitable, Dict, List, Optional
import voluptuous as vol import voluptuous as vol
from voluptuous.humanize import humanize_error from voluptuous.humanize import humanize_error
@ -35,6 +35,7 @@ from ..const import (
ATTR_USER, ATTR_USER,
ATTR_UUID, ATTR_UUID,
ATTR_VERSION, ATTR_VERSION,
DNS_SUFFIX,
STATE_NONE, STATE_NONE,
STATE_STARTED, STATE_STARTED,
STATE_STOPPED, STATE_STOPPED,
@ -119,6 +120,11 @@ class Addon(AddonModel):
"""Return installed version.""" """Return installed version."""
return self.persist[ATTR_VERSION] return self.persist[ATTR_VERSION]
@property
def dns(self) -> List[str]:
"""Return list of DNS name for that add-on."""
return [f"{self.hostname}.{DNS_SUFFIX}"]
@property @property
def options(self) -> Dict[str, Any]: def options(self) -> Dict[str, Any]:
"""Return options with local changes.""" """Return options with local changes."""

View File

@ -114,6 +114,11 @@ class AddonModel(CoreSysAttributes):
"""Return slug/id of add-on.""" """Return slug/id of add-on."""
return self.slug.replace("_", "-") return self.slug.replace("_", "-")
@property
def dns(self) -> List[str]:
"""Return list of DNS name for that add-on."""
return []
@property @property
def timeout(self) -> int: def timeout(self) -> int:
"""Return timeout of addon for docker stop.""" """Return timeout of addon for docker stop."""

View File

@ -30,6 +30,7 @@ from ..const import (
ATTR_DEVICES, ATTR_DEVICES,
ATTR_DEVICETREE, ATTR_DEVICETREE,
ATTR_DISCOVERY, ATTR_DISCOVERY,
ATTR_DNS,
ATTR_DOCKER_API, ATTR_DOCKER_API,
ATTR_FULL_ACCESS, ATTR_FULL_ACCESS,
ATTR_GPIO, ATTR_GPIO,
@ -182,6 +183,7 @@ class APIAddons(CoreSysAttributes):
ATTR_NAME: addon.name, ATTR_NAME: addon.name,
ATTR_SLUG: addon.slug, ATTR_SLUG: addon.slug,
ATTR_HOSTNAME: addon.hostname, ATTR_HOSTNAME: addon.hostname,
ATTR_DNS: addon.dns,
ATTR_DESCRIPTON: addon.description, ATTR_DESCRIPTON: addon.description,
ATTR_LONG_DESCRIPTION: addon.long_description, ATTR_LONG_DESCRIPTION: addon.long_description,
ATTR_AUTO_UPDATE: None, ATTR_AUTO_UPDATE: None,