fix resource loading from pkg
This commit is contained in:
parent
72b5e19ffe
commit
651c166920
4 changed files with 13 additions and 10 deletions
2
build.py
2
build.py
|
@ -28,7 +28,7 @@ use_plugin("python.distutils")
|
|||
default_task = "publish"
|
||||
|
||||
name = "ddadevops"
|
||||
version = "4.0.0-dev21"
|
||||
version = "4.0.0-dev26"
|
||||
summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
|
||||
description = __doc__
|
||||
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]
|
||||
|
|
|
@ -17,30 +17,30 @@ class ImageBuildService:
|
|||
)
|
||||
|
||||
def __copy_build_resource_file_from_package__(self, resource_name, devops: Devops):
|
||||
data = self.resource_api.read_resource(f"src/main/resources/docker/{resource_name}")
|
||||
data = self.resource_api.read_resource(f"main/resources/docker/{resource_name}")
|
||||
self.file_api.write_data_to_file(
|
||||
f"{devops.build_path()}/{resource_name}", data
|
||||
)
|
||||
|
||||
def __copy_build_resources_from_package__(self, devops: Devops):
|
||||
self.__copy_build_resource_file_from_package__(
|
||||
"image/resources/install_functions.sh", devops.specialized_builds[BuildType.C4K]
|
||||
"image/resources/install_functions.sh", devops.specialized_builds[BuildType.IMAGE]
|
||||
)
|
||||
|
||||
def __copy_build_resources_from_dir__(self, devops: Devops):
|
||||
image = devops.specialized_builds[BuildType.C4K]
|
||||
image = devops.specialized_builds[BuildType.IMAGE]
|
||||
self.file_api.cp_force(
|
||||
image.build_commons_path(), devops.build_path()
|
||||
)
|
||||
|
||||
def initialize_build_dir(self, devops: Devops):
|
||||
image = devops.specialized_builds[BuildType.C4K]
|
||||
image = devops.specialized_builds[BuildType.IMAGE]
|
||||
build_path = devops.build_path()
|
||||
self.file_api.clean_dir(f"{build_path}/image/resources")
|
||||
if image.image_use_package_common_files:
|
||||
self.__copy_build_resources_from_package__(image)
|
||||
self.__copy_build_resources_from_package__(devops)
|
||||
else:
|
||||
self.__copy_build_resources_from_dir__(image)
|
||||
self.__copy_build_resources_from_dir__(devops)
|
||||
self.file_api.cp_recursive("image", build_path)
|
||||
self.file_api.cp_recursive("test", build_path)
|
||||
|
||||
|
@ -51,13 +51,13 @@ class ImageBuildService:
|
|||
self.image_api.drun(devops.name)
|
||||
|
||||
def dockerhub_login(self, devops: Devops):
|
||||
image = devops.specialized_builds[BuildType.C4K]
|
||||
image = devops.specialized_builds[BuildType.IMAGE]
|
||||
self.image_api.dockerhub_login(
|
||||
image.image_dockerhub_user, image.image_dockerhub_password
|
||||
)
|
||||
|
||||
def dockerhub_publish(self, devops: Devops):
|
||||
image = devops.specialized_builds[BuildType.C4K]
|
||||
image = devops.specialized_builds[BuildType.IMAGE]
|
||||
if image.image_tag is None or image.image_tag == "":
|
||||
raise ValueError(f"image_tag must not be empty.")
|
||||
self.image_api.dockerhub_publish(
|
||||
|
|
|
@ -25,6 +25,9 @@ class Image(Validateable):
|
|||
result = []
|
||||
result += self.__validate_is_not_empty__("image_dockerhub_user")
|
||||
result += self.__validate_is_not_empty__("image_dockerhub_password")
|
||||
if not self.image_use_package_common_files:
|
||||
result += self.__validate_is_not_empty__("image_build_commons_path")
|
||||
result += self.__validate_is_not_empty__("image_build_commons_dir_name")
|
||||
return result
|
||||
|
||||
def build_commons_path(self):
|
||||
|
|
|
@ -9,7 +9,7 @@ from ..domain import Devops, Image, C4k, Release, BuildFile
|
|||
|
||||
class ResourceApi:
|
||||
def read_resource(self, path: str) -> bytes:
|
||||
return resource_string(__name__, path)
|
||||
return resource_string('src', path)
|
||||
|
||||
|
||||
class FileApi:
|
||||
|
|
Loading…
Reference in a new issue