mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-27 02:56:31 +00:00
commit
39cc8aaa13
@ -9,7 +9,6 @@ RUN apk add --no-cache \
|
|||||||
git \
|
git \
|
||||||
socat \
|
socat \
|
||||||
glib \
|
glib \
|
||||||
libstdc++ \
|
|
||||||
eudev \
|
eudev \
|
||||||
eudev-libs
|
eudev-libs
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from ipaddress import ip_network
|
from ipaddress import ip_network
|
||||||
|
|
||||||
HASSIO_VERSION = "191"
|
HASSIO_VERSION = "192"
|
||||||
|
|
||||||
|
|
||||||
URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons"
|
URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons"
|
||||||
|
@ -2,18 +2,15 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict
|
from typing import Dict, Union
|
||||||
|
|
||||||
from ruamel.yaml import YAML, YAMLError
|
from ruamel.yaml import YAML, YAMLError
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from .coresys import CoreSys, CoreSysAttributes
|
from .coresys import CoreSys, CoreSysAttributes
|
||||||
from .utils import AsyncThrottle
|
from .utils import AsyncThrottle
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
SECRETS_SCHEMA = vol.Schema({str: vol.Any(str, int, None, float)})
|
|
||||||
|
|
||||||
|
|
||||||
class SecretsManager(CoreSysAttributes):
|
class SecretsManager(CoreSysAttributes):
|
||||||
"""Manage Home Assistant secrets."""
|
"""Manage Home Assistant secrets."""
|
||||||
@ -21,14 +18,14 @@ class SecretsManager(CoreSysAttributes):
|
|||||||
def __init__(self, coresys: CoreSys):
|
def __init__(self, coresys: CoreSys):
|
||||||
"""Initialize secret manager."""
|
"""Initialize secret manager."""
|
||||||
self.coresys: CoreSys = coresys
|
self.coresys: CoreSys = coresys
|
||||||
self.secrets: Dict[str, str] = {}
|
self.secrets: Dict[str, Union[bool, float, int, str]] = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_secrets(self) -> Path:
|
def path_secrets(self) -> Path:
|
||||||
"""Return path to secret file."""
|
"""Return path to secret file."""
|
||||||
return Path(self.sys_config.path_homeassistant, "secrets.yaml")
|
return Path(self.sys_config.path_homeassistant, "secrets.yaml")
|
||||||
|
|
||||||
def get(self, secret: str) -> str:
|
def get(self, secret: str) -> Union[bool, float, int, str]:
|
||||||
"""Get secret from store."""
|
"""Get secret from store."""
|
||||||
_LOGGER.info("Request secret %s", secret)
|
_LOGGER.info("Request secret %s", secret)
|
||||||
return self.secrets.get(secret)
|
return self.secrets.get(secret)
|
||||||
@ -53,12 +50,15 @@ class SecretsManager(CoreSysAttributes):
|
|||||||
# Read secrets
|
# Read secrets
|
||||||
try:
|
try:
|
||||||
yaml = YAML()
|
yaml = YAML()
|
||||||
|
yaml.allow_duplicate_keys = True
|
||||||
data = await self.sys_run_in_executor(yaml.load, self.path_secrets) or {}
|
data = await self.sys_run_in_executor(yaml.load, self.path_secrets) or {}
|
||||||
|
|
||||||
self.secrets = SECRETS_SCHEMA(data)
|
# Filter to only get supported values
|
||||||
|
self.secrets = {
|
||||||
|
k: v for k, v in data.items() if isinstance(v, (bool, float, int, str))
|
||||||
|
}
|
||||||
|
|
||||||
except YAMLError as err:
|
except YAMLError as err:
|
||||||
_LOGGER.error("Can't process Home Assistant secrets: %s", err)
|
_LOGGER.error("Can't process Home Assistant secrets: %s", err)
|
||||||
except vol.Invalid:
|
|
||||||
_LOGGER.warning("Home Assistant secrets have a invalid format")
|
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug("Reload Home Assistant secrets: %s", len(self.secrets))
|
_LOGGER.debug("Reload Home Assistant secrets: %s", len(self.secrets))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
flake8==3.7.8
|
flake8==3.7.8
|
||||||
pylint==2.4.3
|
pylint==2.4.3
|
||||||
pytest==5.2.1
|
pytest==5.2.2
|
||||||
pytest-timeout==1.3.3
|
pytest-timeout==1.3.3
|
||||||
pytest-aiohttp==0.3.0
|
pytest-aiohttp==0.3.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user