openstack-image-manager icon indicating copy to clipboard operation
openstack-image-manager copied to clipboard

Include configuration for how to update versions into yaml file

Open mbuechse opened this issue 2 years ago • 0 comments

Currently, the update script contains a case distinction for several hard-coded distros, like so:

        if image["shortname"] in ["rocky-8", "rocky-9"]:
            splitted_line = re.split("\s+", line)  # noqa W605
            if splitted_line[0] == "SHA256":
                checksums[latest_filename] = splitted_line[3]
        elif image["shortname"] in [
            "ubuntu-14.04",
            "ubuntu-16.04",
            "ubuntu-16.04-minimal",
            "ubuntu-18.04",
            "ubuntu-18.04-minimal",
            "ubuntu-20.04",
            "ubuntu-20.04-minimal",
            "ubuntu-22.04",
            "ubuntu-22.04-minimal",
        ]:
            splitted_line = re.split("\s+", line)  # noqa W605
            if len(splitted_line) == 2:
                checksums[splitted_line[1][1:]] = splitted_line[0]
        elif image["shortname"] in ["centos-7"]:
            splitted_line = re.split("\s+", line)  # noqa W605
            if len(splitted_line) == 2:
                if re.search(filename_pattern, splitted_line[1]):
                    checksums[splitted_line[1]] = splitted_line[0]
        elif image["shortname"] in ["centos-stream-8", "centos-stream-9"]:
            splitted_line = re.split("\s+", line)  # noqa W605
            if splitted_line[0] == "SHA256" and re.search(
                filename_pattern, splitted_line[1][1:-1]
            ):
                checksums[splitted_line[1][1:-1]] = splitted_line[3]
        else:
            splitted_line = re.split("\s+", line)  # noqa W605
            if len(splitted_line) == 2:
                checksums[splitted_line[1]] = splitted_line[0]

I'm wondering if we could abstract the concrete distros away by identifying a number of general cases with general parameters, and then include the case as well as the parameters in the yaml.

mbuechse avatar Aug 18 '23 11:08 mbuechse