diff --git a/hassio/addons/data.py b/hassio/addons/data.py index fe88551a0..e4eae0a95 100644 --- a/hassio/addons/data.py +++ b/hassio/addons/data.py @@ -13,8 +13,8 @@ from .validate import ( from ..const import ( FILE_HASSIO_ADDONS, ATTR_NAME, ATTR_VERSION, ATTR_SLUG, ATTR_DESCRIPTON, ATTR_STARTUP, ATTR_BOOT, ATTR_MAP, ATTR_OPTIONS, ATTR_PORTS, BOOT_AUTO, - DOCKER_REPO, ATTR_SCHEMA, ATTR_IMAGE, MAP_CONFIG, MAP_SSL, MAP_ADDONS, - MAP_BACKUP, ATTR_REPOSITORY, ATTR_URL, ATTR_ARCH, ATTR_LOCATON) + ATTR_SCHEMA, ATTR_IMAGE, MAP_CONFIG, MAP_SSL, MAP_ADDONS, MAP_BACKUP, + ATTR_REPOSITORY, ATTR_URL, ATTR_ARCH, ATTR_LOCATON) from ..config import Config from ..tools import read_json_file, write_json_file @@ -308,28 +308,20 @@ class AddonsData(Config): addon, self._addons_cache.get(addon) ) - # core repository - if addon_data[ATTR_REPOSITORY] == REPOSITORY_CORE: - return "{}/{}-addon-{}".format( - DOCKER_REPO, self.arch, addon_data[ATTR_SLUG]) - # Repository with dockerhub images if ATTR_IMAGE in addon_data: return addon_data[ATTR_IMAGE].format(arch=self.arch) - # Local build addon - if addon_data[ATTR_REPOSITORY] == REPOSITORY_LOCAL: - return "local/{}-addon-{}".format(self.arch, addon_data[ATTR_SLUG]) - - _LOGGER.error("No image for %s", addon) + # local build + return "{}/{}-addon-{}".format( + addon_data[ATTR_REPOSITORY], self.arch, addon_data[ATTR_SLUG]) def need_build(self, addon): - """Return True if this addon need a local build.""" + """Return True if this addon need a local build.""" addon_data = self._system_data.get( addon, self._addons_cache.get(addon) ) - return addon_data[ATTR_REPOSITORY] == REPOSITORY_LOCAL \ - and not addon_data.get(ATTR_IMAGE) + return ATTR_IMAGE not in addon_data def map_config(self, addon): """Return True if config map is needed.""" diff --git a/hassio/const.py b/hassio/const.py index 53b19b7e9..51747567e 100644 --- a/hassio/const.py +++ b/hassio/const.py @@ -10,8 +10,6 @@ URL_HASSIO_VERSION_BETA = ('https://raw.githubusercontent.com/home-assistant/' URL_HASSIO_ADDONS = 'https://github.com/home-assistant/hassio-addons' -DOCKER_REPO = "homeassistant" - HASSIO_SHARE = Path("/data") RUN_UPDATE_INFO_TASKS = 28800 diff --git a/hassio/dock/__init__.py b/hassio/dock/__init__.py index c78b32826..ac585ea75 100644 --- a/hassio/dock/__init__.py +++ b/hassio/dock/__init__.py @@ -51,13 +51,13 @@ class DockerBase(object): _LOGGER.info("Pull image %s tag %s.", self.image, tag) image = self.dock.images.pull("{}:{}".format(self.image, tag)) + self.version = tag image.tag(self.image, tag='latest') - self.version = get_version_from_env(image.attrs['Config']['Env']) - _LOGGER.info("Tag image %s with version %s as latest", - self.image, self.version) except docker.errors.APIError as err: _LOGGER.error("Can't install %s:%s -> %s.", self.image, tag, err) return False + + _LOGGER.info("Tag image %s with version %s as latest", self.image, tag) return True def exists(self): diff --git a/hassio/dock/addon.py b/hassio/dock/addon.py index 88ace43d7..8a32569ab 100644 --- a/hassio/dock/addon.py +++ b/hassio/dock/addon.py @@ -159,12 +159,14 @@ class DockerAddon(DockerBase): image = self.dock.images.build( path=str(build_dir), tag=build_tag, pull=True) - _LOGGER.info("Build %s done", build_tag) + self.version = tag image.tag(self.image, tag='latest') + except (docker.errors.DockerException, TypeError) as err: _LOGGER.error("Can't build %s -> %s", build_tag, err) return False + _LOGGER.info("Build %s done", build_tag) return True finally: