Skip to main content

Materializer

Trait Materializer 

Source
pub trait Materializer: Send + Sync {
    // Required method
    fn materialize(
        &self,
        path: &Path,
        environment: &BTreeMap<String, String>,
    ) -> Result<(), MaterializerError>;
}
Expand description

Produce a .env file from a resolved key/value environment.

“Resolved” means the caller has already fetched values from the metadata store and the secret store and applied the profile’s overrides. The materializer’s job is purely textual: emit a well-formed .env, attach the “generated by evault” header, and update the project .gitignore so the file is never committed.

Required Methods§

Source

fn materialize( &self, path: &Path, environment: &BTreeMap<String, String>, ) -> Result<(), MaterializerError>

Write environment to path, replacing any prior content.

The materializer must:

  • prepend a header marking the file as generated;
  • ensure path’s parent directory exists;
  • update a sibling .gitignore so that the basename of path is ignored;
  • write atomically (write-then-rename) so partial files never appear.
§Errors

Returns MaterializerError::Io on file-system failure or MaterializerError::Backend for higher-level problems.

Implementors§