MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / pgdata_template_asset_out

Function pgdata_template_asset_out

xtask/src/main.rs:9193–9225  ·  view source on GitHub ↗
(
    sources: &SourcesManifest,
    runtime_module: &Path,
    initdb_module: &Path,
    archive: &Path,
    manifest: &Path,
)

Source from the content-addressed store, hash-verified

9191}
9192
9193fn pgdata_template_asset_out(
9194 sources: &SourcesManifest,
9195 runtime_module: &Path,
9196 initdb_module: &Path,
9197 archive: &Path,
9198 manifest: &Path,
9199) -> Result<PgDataTemplateAssetOut> {
9200 ensure_file(archive)?;
9201 ensure_file(manifest)?;
9202 let manifest_text =
9203 fs::read_to_string(manifest).with_context(|| format!("read {}", manifest.display()))?;
9204 let manifest_json: serde_json::Value = serde_json::from_str(&manifest_text)
9205 .with_context(|| format!("parse {}", manifest.display()))?;
9206 Ok(PgDataTemplateAssetOut {
9207 archive: "prepopulated/pgdata-template.tar.zst".to_owned(),
9208 manifest: "prepopulated/pgdata-template.json".to_owned(),
9209 sha256: sha256_file(archive)?,
9210 size: fs::metadata(archive)
9211 .with_context(|| format!("metadata {}", archive.display()))?
9212 .len(),
9213 runtime_module_sha256: sha256_file(runtime_module)?,
9214 initdb_module_sha256: sha256_file(initdb_module)?,
9215 source_pins_sha256: source_pins_sha256(sources)?,
9216 postgres_version: "17".to_owned(),
9217 catalog_version: manifest_json
9218 .get("catalogVersion")
9219 .and_then(serde_json::Value::as_str)
9220 .unwrap_or("unknown")
9221 .to_owned(),
9222 init_profile: default_initdb_profile().to_owned(),
9223 wasmer_version: sources.toolchain.wasmer.clone(),
9224 })
9225}
9226
9227fn source_pins_sha256(sources: &SourcesManifest) -> Result<String> {
9228 let pins = serde_json::to_vec(&sources.sources).context("serialize source pins")?;

Callers 1

write_asset_manifestFunction · 0.85

Calls 5

ensure_fileFunction · 0.85
source_pins_sha256Function · 0.85
default_initdb_profileFunction · 0.85
lenMethod · 0.80
sha256_fileFunction · 0.70

Tested by

no test coverage detected