Validate build env before using it (#2492)

This commit is contained in:
Pascal Vizeli 2021-02-01 09:46:48 +01:00 committed by GitHub
parent 509a37fc04
commit 72db591576
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -48,6 +48,14 @@ class AddonBuild(JsonConfig, CoreSysAttributes):
"""Return additional Docker build arguments."""
return self._data[ATTR_ARGS]
@property
def is_valid(self) -> bool:
"""Return true if the build env is valid."""
return all(
self.addon.path_location.is_dir(),
Path(self.addon.path_location, "Dockerfile").is_file(),
)
def get_docker_args(self, version: AwesomeVersion):
"""Create a dict with Docker build arguments."""
args = {

View File

@ -423,6 +423,9 @@ class DockerAddon(DockerInterface):
Need run inside executor.
"""
build_env = AddonBuild(self.coresys, self.addon)
if not build_env.is_valid:
_LOGGER.error("Invalid build envoirement, can't build this add-on!")
raise DockerError()
_LOGGER.info("Starting build for %s:%s", self.image, version)
try: