MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / __init__

Method __init__

misc/python/materialize/mzbuild.py:889–922  ·  view source on GitHub ↗
(self, rd: RepositoryDetails, path: Path)

Source from the content-addressed store, hash-verified

887 _context_files_cache: set[str] | None
888
889 def __init__(self, rd: RepositoryDetails, path: Path):
890 self.rd = rd
891 self.path = path
892 self._context_files_cache = None
893 self.pre_images: list[PreImage] = []
894 with open(self.path / "mzbuild.yml") as f:
895 data = yaml.safe_load(f)
896 self.name: str = data.pop("name")
897 self.publish: bool = data.pop("publish", True)
898 self.description: str | None = data.pop("description", None)
899 self.mainline: bool = data.pop("mainline", True)
900 for pre_image in data.pop("pre-image", []):
901 typ = pre_image.pop("type", None)
902 if typ == "cargo-build":
903 self.pre_images.append(CargoBuild(self.rd, self.path, pre_image))
904 elif typ == "copy":
905 self.pre_images.append(Copy(self.rd, self.path, pre_image))
906 else:
907 raise ValueError(
908 f"mzbuild config in {self.path} has unknown pre-image type"
909 )
910 self.build_args = data.pop("build-args", {})
911
912 if re.search(r"[^A-Za-z0-9\-]", self.name):
913 raise ValueError(
914 f"mzbuild image name {self.name} contains invalid character; only alphanumerics and hyphens allowed"
915 )
916
917 self.depends_on: list[str] = []
918 with open(self.path / "Dockerfile", "rb") as f:
919 for line in f:
920 match = self._DOCKERFILE_MZFROM_RE.match(line)
921 if match:
922 self.depends_on.append(match.group(1).decode())
923
924 def sync_description(self) -> None:
925 """Sync the description to Docker Hub if the image is publishable

Callers

nothing calls this directly

Calls 7

CargoBuildClass · 0.85
CopyClass · 0.85
ValueErrorClass · 0.85
groupMethod · 0.80
popMethod · 0.45
appendMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected