| 18 | |
| 19 | |
| 20 | class Mz(Service): |
| 21 | def __init__( |
| 22 | self, |
| 23 | *, |
| 24 | name: str = "mz", |
| 25 | region: str = "aws/us-east-1", |
| 26 | environment: str = "staging", |
| 27 | app_password: str, |
| 28 | ) -> None: |
| 29 | |
| 30 | # Production env does not require to specify an endpoint. |
| 31 | if environment == "production": |
| 32 | cloud_endpoint = None |
| 33 | admin_endpoint = None |
| 34 | else: |
| 35 | cloud_endpoint = f"https://api.{environment}.cloud.materialize.com" |
| 36 | admin_endpoint = f"https://admin.{environment}.cloud.materialize.com" |
| 37 | |
| 38 | config_str = toml.dumps( |
| 39 | { |
| 40 | "profile": "default", |
| 41 | "profiles": { |
| 42 | "default": { |
| 43 | "app-password": app_password, |
| 44 | "region": region, |
| 45 | "cloud-endpoint": cloud_endpoint, |
| 46 | "admin-endpoint": admin_endpoint, |
| 47 | }, |
| 48 | }, |
| 49 | }, |
| 50 | ) |
| 51 | |
| 52 | # We must create the temporary config file in a location |
| 53 | # that is accessible on the same path in both the ci-builder |
| 54 | # container and the host that runs the docker daemon |
| 55 | # $TMP does not guarantee that, but loader.composition_path does. |
| 56 | config_hash = hashlib.sha256(config_str.encode()).hexdigest() |
| 57 | config_name = (loader.composition_path or MZ_ROOT) / f"tmp_{config_hash}.toml" |
| 58 | |
| 59 | with open(config_name, "w") as f: |
| 60 | f.write(config_str) |
| 61 | os.chmod(config_name, 0o777) |
| 62 | super().__init__( |
| 63 | name=name, |
| 64 | config={ |
| 65 | "mzbuild": "mz", |
| 66 | "volumes": [ |
| 67 | f"{config_name}:/home/materialize/.config/materialize/mz.toml" |
| 68 | ], |
| 69 | }, |
| 70 | ) |
no outgoing calls
no test coverage detected