[][src]Crate liboverdrop

Simple library to handle configuration fragments.

This crate provides helpers to scan configuration fragments on disk. The goal is to help in writing Linux services which are shipped as part of a Reproducible OS. Its name derives from overlays and dropins (base directories and configuration fragments).

The main entrypoint is FragmentScanner. It scans for configuration fragments across multiple directories (with increasing priority), following these rules:

  • fragments are identified by unique filenames, lexicographically (e.g. 50-default-limits.conf).
  • in case of name duplication, last directory wins (e.g. /etc/svc/custom.conf can override /usr/lib/svc/custom.conf).
  • a fragment symlinked to /dev/null is used to ignore any previous fragment with the same filename.

Example

// Scan for fragments under:
//  * /usr/lib/my-crate/config.d/*.toml
//  * /run/my-crate/config.d/*.toml
//  * /etc/my-crate/config.d/*.toml

let base_dirs = vec![
    "/usr/lib".to_string(),
    "/run".to_string(),
    "/etc".to_string(),
];
let allowed_extensions = vec![
    String::from("toml"),
];
let od_cfg = FragmentScanner::new(base_dirs, "my-crate/config.d", false, allowed_extensions);

let fragments = od_cfg.scan();
for (filename, filepath) in fragments {
    println!("fragment '{}' located at '{}'", filename, filepath.display());
}

Structs

FragmentScanner

Configuration fragments scanner.