mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-27 02:56:31 +00:00
Allow moving registry for supervisor (#1667)
* Allow moving registry for supervisor * fix * Filter number
This commit is contained in:
parent
0f4810d41f
commit
c2cfc0d3d4
@ -77,3 +77,30 @@ class DockerSupervisor(DockerInterface, CoreSysAttributes):
|
|||||||
except docker.errors.DockerException as err:
|
except docker.errors.DockerException as err:
|
||||||
_LOGGER.error("Can't retag supervisor version: %s", err)
|
_LOGGER.error("Can't retag supervisor version: %s", err)
|
||||||
raise DockerAPIError() from None
|
raise DockerAPIError() from None
|
||||||
|
|
||||||
|
def update_start_tag(self, image: str, version: str) -> Awaitable[None]:
|
||||||
|
"""Update start tag to new version."""
|
||||||
|
return self.sys_run_in_executor(self._update_start_tag, image, version)
|
||||||
|
|
||||||
|
def _update_start_tag(self, image: str, version: str) -> None:
|
||||||
|
"""Update start tag to new version.
|
||||||
|
|
||||||
|
Need run inside executor.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
docker_container = self.sys_docker.containers.get(self.name)
|
||||||
|
docker_image = self.sys_docker.images.get(f"{image}:{version}")
|
||||||
|
|
||||||
|
# Find start tag
|
||||||
|
for tag in docker_container.image.tags:
|
||||||
|
start_image = tag.partition(":")[0]
|
||||||
|
start_tag = tag.partition(":")[2] or "latest"
|
||||||
|
|
||||||
|
# If version tag
|
||||||
|
if start_tag.isdigit():
|
||||||
|
continue
|
||||||
|
docker_image.tag(start_image, start_tag)
|
||||||
|
|
||||||
|
except docker.errors.DockerException as err:
|
||||||
|
_LOGGER.error("Can't fix start tag: %s", err)
|
||||||
|
raise DockerAPIError() from None
|
||||||
|
@ -116,7 +116,10 @@ class Supervisor(CoreSysAttributes):
|
|||||||
_LOGGER.info("Update Supervisor to version %s", version)
|
_LOGGER.info("Update Supervisor to version %s", version)
|
||||||
try:
|
try:
|
||||||
await self.instance.install(
|
await self.instance.install(
|
||||||
version, image=self.sys_updater.image_supervisor, latest=True
|
version, image=self.sys_updater.image_supervisor
|
||||||
|
)
|
||||||
|
await self.instance.update_start_tag(
|
||||||
|
self.sys_updater.image_supervisor, version
|
||||||
)
|
)
|
||||||
except DockerAPIError:
|
except DockerAPIError:
|
||||||
_LOGGER.error("Update of Supervisor fails!")
|
_LOGGER.error("Update of Supervisor fails!")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user