Skip to main content

Crate lightshuttle_secrets

Crate lightshuttle_secrets 

Source
Expand description

Secret sources and .env file loading for LightShuttle.

This crate provides a pluggable system for loading environment variables and secrets. It forms a leaf layer of LightShuttle: it has no internal dependencies and is used by higher layers to interpolate ${env.VAR} references in manifests.

The core abstraction is the SecretSource trait, which any backing store can implement to expose key-value pairs. A built-in EnvFileSource implementation parses .env files using POSIX-like syntax (supporting quoted values, comments, and optional export prefix).

§Example: Load a .env file

use lightshuttle_secrets::EnvFileSource;
use std::path::Path;

let source = EnvFileSource::load(path)?;
println!("Loaded {} entries from .env", source.len());

§Example: Load .env optionally (default file)

use lightshuttle_secrets::EnvFileSource;

// Returns None if the file does not exist (no error)
if let Some(source) = EnvFileSource::load_optional(path)? {
    println!("Using {} secrets from .env", source.len());
} else {
    println!("No .env file found; using defaults");
}

Re-exports§

pub use error::SecretError;
pub use source::EnvFileSource;
pub use source::SecretSource;

Modules§

error
Error types for secret loading.
source
Secret source trait and built-in implementations.