Skip to main content

hypercall/catalog_manager/
config.rs

1//! Catalog configuration runtime loading.
2//!
3//! Pure catalog config types and validation live in the `catalog-manager`
4//! crate. This module keeps filesystem reads in the `hypercall` runtime crate.
5
6use anyhow::{Context, Result};
7use catalog_manager::{parse_catalog_config, CatalogConfig};
8use std::path::Path;
9
10pub fn load_catalog_config<P: AsRef<Path>>(path: P) -> Result<CatalogConfig> {
11    let path = path.as_ref();
12    let contents = std::fs::read_to_string(path)
13        .with_context(|| format!("Failed to read catalog config from {:?}", path))?;
14    parse_catalog_config(&contents)
15        .with_context(|| format!("Failed to parse catalog config from {:?}", path))
16}