mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 15:16:33 +00:00
Supervisor image handler (#2757)
This commit is contained in:
parent
900b785789
commit
98f8e032e3
@ -14,6 +14,7 @@ from .const import (
|
||||
ATTR_DEBUG_BLOCK,
|
||||
ATTR_DIAGNOSTICS,
|
||||
ATTR_FORCE_SECURITY,
|
||||
ATTR_IMAGE,
|
||||
ATTR_LAST_BOOT,
|
||||
ATTR_LOGGING,
|
||||
ATTR_TIMEZONE,
|
||||
@ -69,14 +70,24 @@ class CoreConfig(FileConfiguration):
|
||||
|
||||
@property
|
||||
def version(self) -> AwesomeVersion:
|
||||
"""Return config version."""
|
||||
"""Return supervisor version."""
|
||||
return self._data[ATTR_VERSION]
|
||||
|
||||
@version.setter
|
||||
def version(self, value: AwesomeVersion) -> None:
|
||||
"""Set config version."""
|
||||
"""Set supervisor version."""
|
||||
self._data[ATTR_VERSION] = value
|
||||
|
||||
@property
|
||||
def image(self) -> Optional[str]:
|
||||
"""Return supervisor image."""
|
||||
return self._data.get(ATTR_IMAGE)
|
||||
|
||||
@image.setter
|
||||
def image(self, value: str) -> None:
|
||||
"""Set supervisor image."""
|
||||
self._data[ATTR_IMAGE] = value
|
||||
|
||||
@property
|
||||
def wait_boot(self) -> int:
|
||||
"""Return wait time for auto boot stages."""
|
||||
|
@ -467,6 +467,9 @@ class DockerInterface(CoreSysAttributes):
|
||||
raise DockerError() from err
|
||||
|
||||
for image in images_list:
|
||||
if origin.id == image.id:
|
||||
continue
|
||||
|
||||
with suppress(docker.errors.DockerException, requests.RequestException):
|
||||
_LOGGER.info("Cleanup images: %s", image.tags)
|
||||
self.sys_docker.images.remove(image.id, force=True)
|
||||
|
@ -102,6 +102,7 @@ class DockerSupervisor(DockerInterface, CoreSysAttributes):
|
||||
if start_tag != "latest":
|
||||
continue
|
||||
docker_image.tag(start_image, start_tag)
|
||||
docker_image.tag(start_image, version.string)
|
||||
|
||||
except (docker.errors.DockerException, requests.RequestException) as err:
|
||||
_LOGGER.error("Can't fix start tag: %s", err)
|
||||
|
@ -46,7 +46,7 @@ class Supervisor(CoreSysAttributes):
|
||||
_LOGGER.critical("Can't setup Supervisor Docker container!")
|
||||
|
||||
with suppress(DockerError):
|
||||
await self.instance.cleanup()
|
||||
await self.instance.cleanup(old_image=self.sys_config.image)
|
||||
|
||||
@property
|
||||
def connectivity(self) -> bool:
|
||||
@ -161,6 +161,7 @@ class Supervisor(CoreSysAttributes):
|
||||
raise SupervisorUpdateError() from err
|
||||
else:
|
||||
self.sys_config.version = version
|
||||
self.sys_config.image = self.sys_updater.image_supervisor
|
||||
self.sys_config.save_data()
|
||||
|
||||
self.sys_create_task(self.sys_core.stop())
|
||||
|
@ -140,6 +140,7 @@ SCHEMA_SUPERVISOR_CONFIG = vol.Schema(
|
||||
vol.Optional(
|
||||
ATTR_VERSION, default=AwesomeVersion(SUPERVISOR_VERSION)
|
||||
): version_tag,
|
||||
vol.Optional(ATTR_IMAGE): docker_image,
|
||||
vol.Optional(
|
||||
ATTR_ADDONS_CUSTOM_LIST,
|
||||
default=["https://github.com/hassio-addons/repository"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user