def check()

in src/build_workflow/opensearch_dashboards/build_artifact_check_plugin.py [0:0]


    def check(self, path: str) -> None:
        if os.path.splitext(path)[1] != ".zip":
            raise BuildArtifactCheck.BuildArtifactInvalidError(path, "Not a zip file.")

        match = re.search(r"^(\w+)-[\d\.]*.*.zip$", os.path.basename(path))
        if not match:
            raise BuildArtifactCheck.BuildArtifactInvalidError(path, "Expected filename to be in the format of pluginName-1.1.0.zip.")

        plugin_name = match.group(1)
        valid_filenames = self.__valid_paths(plugin_name)
        if not os.path.basename(path) in valid_filenames:
            raise BuildArtifactCheck.BuildArtifactInvalidError(path, f"Expected filename to to be one of {valid_filenames}.")

        with ZipFile(path, "r") as zip:
            data = zip.read(f"opensearch-dashboards/{plugin_name}/opensearch_dashboards.json").decode("UTF-8")
            config = ConfigFile(data)
            try:
                config.check_value_in("version", self.target.compatible_component_versions)
                config.check_value_in("opensearchDashboardsVersion", self.target.compatible_versions)
            except ConfigFile.CheckError as e:
                raise BuildArtifactCheck.BuildArtifactInvalidError(path, e.__str__())
            logging.info(f'Checked {path} ({config.get_value("version", "N/A")})')