Пример #1
0
    def push_changes(self):
        """Pushes changes for all components into downstream dist-git repository"""
        # Check for kerberos ticket
        self._check_kerb_ticket()
        tmp = self._get_tmp_workdir(setup_dir=False)
        if not tmp:
            raise RebuilderError(
                "Temporary directory structure does not exist. Pull upstream/rebase first."
            )
        self._change_workdir(tmp)
        images = self._get_images()

        self.distgit.push_changes(tmp, images)
Пример #2
0
 def _prebuild_check(self, image_set: List, branches: List = None):
     tmp = self._get_tmp_workdir(setup_dir=False)
     if not tmp:
         msg = "Temporary directory structure does not exist. Pull upstream first."
         raise RebuilderError(msg)
     self.logger.info("Checking for correct repository configuration ...")
     releases = branches
     for image in image_set:
         component = image["component"]
         cwd = os.path.join(tmp, component)
         try:
             repo = Repo(cwd)
         except GitError as e:
             self.logger.error("Failed to open repository for {}",
                               component)
             raise e
         # This checks if any of the releases can be found in the name of the checked-out branch
         if releases and not [
                 i for i in releases if i in str(repo.active_branch)
         ]:
             msg = f"Unexpected active branch for {component}: {repo.active_branch}"
             raise RebuilderError(msg)
Пример #3
0
    def get_commit_msg(self, rebase, image=None):
        """Method to create a commit message to be used in git operations

        Returns a general commit message depending on the value of the rebase
        argument, or the user-specified commit message.

        Args:
            rebase (bool): Specify if the rebase message is created
            image (dict, optional): Metadata about the image being processed

        Returns:
            str: Resulting commit message text
        """
        if self.commit_msg is not None:
            return self.commit_msg
        if rebase is True:
            commit = "Rebuild for: {}".format(self.rebuild_reason)
        elif rebase is False:
            t = "Pull changes from upstream and rebase for: {}"
            commit = t.format(self.rebuild_reason)
        else:
            t = "Unknown rebase argument provided: {}"
            raise RebuilderError(t.format(str(rebase)))
        return commit
def _check_base(base_image):
    if not base_image:
        raise RebuilderError("Base image needs to be set.")
Пример #5
0
 def _check_kerb_ticket(self):
     if not self.disable_klist:
         ret = subprocess.run(["klist"], stdout=subprocess.DEVNULL)
         if ret.returncode:
             raise (RebuilderError("Kerberos token not found."))
Пример #6
0
 def _get_set_from_config(self, layer):
     i = getattr(self.conf, layer, [])
     if i is None:
         err_msg = "Image set '{}' not found in config.".format(layer)
         raise RebuilderError(err_msg)
     return i
Пример #7
0
 def base_image(self):
     if not self._base_image:
         raise RebuilderError("Base image needs to be set.")
     return self._base_image